public void Configure(EntityTypeBuilder <CatalogCategory> builder)
        {
            builder
            .Property(x => x.Id)
            .UsePropertyAccessMode(PropertyAccessMode.Field)
            .HasConversion(x => x.Id, id => CatalogCategoryId.Of(id));

            builder
            .Property(x => x.CatalogId)
            .IsRequired()
            .HasConversion(x => x.Id, id => CatalogId.Of(id));

            builder
            .Property(x => x.CategoryId)
            .IsRequired()
            .HasConversion(x => x.Id, id => CategoryId.Of(id));

            builder
            .HasOne(x => x.Parent)
            .WithMany()
            .HasForeignKey("CatalogCategoryParentId")
            .IsRequired(false);

            builder.Ignore(x => x.IsRoot);
        }
コード例 #2
0
        public void Configure(EntityTypeBuilder <Catalog> builder)
        {
            builder
            .Property(x => x.Id)
            .UsePropertyAccessMode(PropertyAccessMode.Field)
            .HasConversion(x => x.Id, id => CatalogId.Of(id));

            builder
            .HasMany(x => x.Categories)
            .WithOne()
            .HasForeignKey(x => x.CatalogId)
            .IsRequired()
            .OnDelete(DeleteBehavior.Cascade);
        }