Migration added and updated

This commit is contained in:
2025-10-08 11:38:42 +01:00
parent 268230daea
commit e4677b1aea
5 changed files with 1763 additions and 802 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Models;
[PrimaryKey(nameof(MaterialId), nameof(WarehouseId))]
public class MaterialWarehouse
{
[Required] public int MaterialId { get; set; }

View File

@@ -77,5 +77,17 @@ public class PyroFetesDbContext : DbContext
.WithMany(w => w.MovementsDestination)
.HasForeignKey(m => m.DestinationWarehouseId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<MaterialWarehouse>()
.HasOne(mw => mw.Material)
.WithMany(m => m.MaterialWarehouses)
.HasForeignKey(mw => mw.MaterialId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<MaterialWarehouse>()
.HasOne(mw => mw.Warehouse)
.WithMany(w => w.MaterialWarehouses)
.HasForeignKey(mw => mw.WarehouseId)
.OnDelete(DeleteBehavior.Restrict);
}
}