CraftMapping.cs 921 B

123456789101112131415161718192021222324252627282930313233
  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 CraftMapping : IEntityTypeConfiguration<Craft>
  10. {
  11. public void Configure(EntityTypeBuilder<Craft> builder)
  12. {
  13. builder.ToTable("Crafts");
  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.CreationDate)
  20. .IsRequired();
  21. builder.HasOne(u => u.Customer)
  22. .WithMany(d => d.Crafts)
  23. .IsRequired()
  24. .OnDelete(DeleteBehavior.Restrict);
  25. }
  26. }
  27. }