CraftMapping.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 CraftMapping : TrackedEntityMapping<Craft>
  11. {
  12. public override void Configure(EntityTypeBuilder<Craft> builder)
  13. {
  14. base.Configure(builder);
  15. builder.ToTable("Crafts");
  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.CreationDate)
  22. .IsRequired();
  23. builder.Property(u => u.Comment)
  24. .IsRequired(false);
  25. builder.HasOne(u => u.Customer)
  26. .WithMany(d => d.Crafts)
  27. .IsRequired()
  28. .OnDelete(DeleteBehavior.Restrict);
  29. }
  30. }
  31. }