![](/img/trans.png)
[英]How to soft-delete records in entity with collection in asp.net core 2?
[英]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.