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行為?
uj5u.com熱心網友回復:
在 Entity Framework Core 中,OnDeleteFluent API 方法用于指定洗掉主體時依賴物體的洗掉行為。EF Core 中默認設定了級聯洗掉,但您可以在 fowling 鏈接上查看所有可以使用它的情況的所有詳細資訊OnDelete
https://entityframeworkcore.com/saving-data-cascade-delete
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451609.html
