12 c# entity-framework .net-core ef-core-2.0
EF Core 中 .WillCascadeOnDelete(false) 的等价物是什么?
modelBuilder.Entity<ProductTransactionHistoryClassImport>()
.HasMany(e => e.ProductTransactionHistoryClassDetailImports)
.WithOne(e => e.ProductTransactionHistoryClassImport)
.WillCascadeOnDelete(false);
Run Code Online (Sandbox Code Playgroud)
seb*_*ebu 18
OnDelete 方法将 DeleteBehavior 枚举作为参数:
Cascade
- 应删除家属
Restrict
- 家属不受影响
SetNull
- 依赖行中的外键值应更新为 NULL
modelBuilder.Entity<ProductTransactionHistoryClassImport>()
.HasMany(e => e.ProductTransactionHistoryClassDetailImports)
.WithOne(e => e.ProductTransactionHistoryClassImport)
.OnDelete(DeleteBehavior.SetNull);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5191 次 |
最近记录: |