簡體   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