I've solved the issue with your help. Thx. This is what I Should code :
internal class ParagraphBaseConfig : IEntityTypeConfiguration<ParagraphBase>
{
public void Configure(EntityTypeBuilder<ParagraphBase> builder)
{
builder.ToTable("Paragraph");
builder
.HasDiscriminator(p => p.ParentType)
.HasValue<SummaryParagraph>(ParagraphBase.ParagraphParentType.ParagraphBlock)
.HasValue<SummaryParagraph>(ParagraphBase.ParagraphParentType.Summary);
}
}
internal class SummaryParagraphConfig : IEntityTypeConfiguration<SummaryParagraph>
{
public void Configure(EntityTypeBuilder<SummaryParagraph> builder)
{
builder.ToTable("Paragraph");
builder
.HasOne<Summary>()
.WithMany(s => s.Paragraphs)
.HasForeignKey(sp => sp.SummaryId)
.OnDelete(DeleteBehavior.Cascade);
builder
.Property(p => p.SummaryId)
.HasColumnName("SummaryId");
}
}
internal class ContentParagraphConfig : IEntityTypeConfiguration<ContentParagraph>
{
public void Configure(EntityTypeBuilder<ContentParagraph> builder)
{
builder.ToTable("Paragraph");
builder
.HasOne<ParagraphBlock>()
.WithMany(pb => pb.Paragraphs)
.HasForeignKey(cp => cp.ParagraphBlockId)
.OnDelete(DeleteBehavior.Cascade);
builder
.Property(p => p.ParagraphBlockId)
.HasColumnName("ParagraphBlockId");
}
}