在这种情况下如何在 EF Core 中设置 onDelete 级联?

How can I set onDelete cascade in this situation in EF Core?

ApplicationDbContext:

protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);

    builder.Entity<Post>().Property(p => p.Name).IsRequired();
    builder.Entity<PostTag>().HasKey(pt => new { pt.PostId, pt.TagId});
    builder.Entity<PostTag>().HasKey(pt => new { pt.PostId, pt.TagId});
            
    builder.Entity<PostCategory>().HasKey(pc => new { pc.PostId, pc.CategoryId });
}

如何实现 OnDelete Cascade 行为?

在Entity FrameworkCore中,OnDeleteFluentAPI方法用于指定删除主体时依赖实体的删除行为。级联删除在 EF Core 中默认设置,但您可以查看 fowling link 的所有详细信息,了解您可以使用它的所有情况 OnDelete

https://entityframeworkcore.com/saving-data-cascade-delete