From fa353446eb39ea7f696697ddc4f1689c2dc100e4 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Mon, 6 Oct 2025 19:35:34 +0100 Subject: [PATCH] Writing OnModelCreating in PyroFetesDbContext.cs. --- PyroFetes/PyroFetesDbContext.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PyroFetes/PyroFetesDbContext.cs b/PyroFetes/PyroFetesDbContext.cs index ae0944c..ac556ea 100644 --- a/PyroFetes/PyroFetesDbContext.cs +++ b/PyroFetes/PyroFetesDbContext.cs @@ -66,5 +66,18 @@ public class PyroFetesDbContext : DbContext // Models customization protected override void OnModelCreating(ModelBuilder modelBuilder) { + // Relation SourceWarehouse + modelBuilder.Entity() + .HasOne(m => m.SourceWarehouse) + .WithMany(w => w.MovementsSource) + .HasForeignKey(m => m.SourceWarehouseId) + .OnDelete(DeleteBehavior.Restrict); // empĂȘche la suppression en cascade + + // Relation DestinationWarehouse + modelBuilder.Entity() + .HasOne(m => m.DestinationWarehouse) + .WithMany(w => w.MovementsDestination) + .HasForeignKey(m => m.DestinationWarehouseId) + .OnDelete(DeleteBehavior.Restrict); } } \ No newline at end of file