MaterialMapping.cs 1.6 KB

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