c#-EF Core中.WillCascadeOnDelete(false)的等效项是什么?
作者:互联网
EF Core中的.WillCascadeOnDelete(false)等效于什么?
modelBuilder.Entity<ProductTransactionHistoryClassImport>()
.HasMany(e => e.ProductTransactionHistoryClassDetailImports)
.WithOne(e => e.ProductTransactionHistoryClassImport);
.WillCascadeOnDelete(false);
解决方法:
OnDelete方法将DeleteBehavior枚举作为参数:
级联-依赖项应删除
限制-家属不受影响
SetNull-相关行中的外键值应更新为NULL
modelBuilder.Entity<ProductTransactionHistoryClassImport>()
.HasMany(e => e.ProductTransactionHistoryClassDetailImports)
.WithOne(e => e.ProductTransactionHistoryClassImport);
.OnDelete(DeleteBehavior.SetNull);
标签:net-core,ef-core-2-0,c,entity-framework 来源: https://codeday.me/bug/20191211/2105611.html