From 2bbb771635ba5d6fc18636860e984a6bd4b74ecc Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Tue, 7 Oct 2025 11:00:35 +0200 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..29fc13b 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); + + // 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