public void Configure(EntityTypeBuilder <Product> builder) { builder .Property(x => x.Id) .UsePropertyAccessMode(PropertyAccessMode.Field) .HasConversion(x => x.Id, id => ProductId.Of(id)); }
public void Configure(EntityTypeBuilder <CatalogProduct> builder) { builder .Property(x => x.Id) .UsePropertyAccessMode(PropertyAccessMode.Field) .HasConversion(x => x.Id, id => CatalogProductId.Of(id)); builder .Property(x => x.ProductId) .IsRequired() .HasConversion(x => x.Id, id => ProductId.Of(id)); builder .HasOne(x => x.CatalogCategory) .WithMany(x => x.Products) .HasForeignKey("CatalogCategoryId") .IsRequired() .OnDelete(DeleteBehavior.Cascade); }