MaterialMapping.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using GreenTree.Strohrmann.ERP.Core.Domain.Business;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. namespace GreenTree.Strohrmann.ERP.Domain.Model.Business
  8. {
  9. public class MaterialMapping : IEntityTypeConfiguration<Material>
  10. {
  11. public void Configure(EntityTypeBuilder<Material> builder)
  12. {
  13. builder.ToTable("Materials");
  14. builder.HasKey(u => u.Id);
  15. builder.Property(u => u.Id)
  16. .ValueGeneratedOnAdd();
  17. builder.Property(u => u.Name)
  18. .IsRequired();
  19. builder.Property(u => u.ItemNumber)
  20. .IsRequired();
  21. builder.Property(u => u.Description)
  22. .IsRequired();
  23. builder.Property(u => u.NetValue)
  24. .IsRequired();
  25. builder.Property(u => u.Height)
  26. .IsRequired();
  27. builder.Property(u => u.Width)
  28. .IsRequired();
  29. builder.Property(u => u.Depth)
  30. .IsRequired();
  31. builder.HasOne(u => u.DefaultUnit)
  32. .WithMany(s => s.Materials)
  33. .IsRequired()
  34. .OnDelete(DeleteBehavior.Restrict);
  35. builder.HasOne(u => u.Supplier)
  36. .WithMany(s => s.Materials)
  37. .IsRequired()
  38. .OnDelete(DeleteBehavior.Restrict);
  39. }
  40. }
  41. }