![](/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.