繁体   English   中英

如何防止级联软删除efcore asp.net

[英]How to prevent cascade soft-delete efcore asp.net

public class item{
   public int id{get;set;}
   public string name{get;set;}
}

public class SalesItem{
   public int id{get;set;}
   public string item_id{get;set;}   
   [ForeignKey(namof(item_id))]
   public virtual Item item{get;set;}
}

有很多类item被引用为foreignkey 如果该项目在另一个表中使用(引用),我需要限制该项目删除(软删除)。

使用.OnDelete(DeleteBehavior.Restrict); 对于OnModelCreating中的实体

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM