[英]Scaffolding Db Context and automatically remove the redundant usings
[英]Automatically turn navigation AutoInclude on when 'Scaffolding' context?
是否可以選擇自動執行此操作? 因為我有一個數據庫第一個情況,當我“腳手架”我的表時,上下文是在沒有這個導航的情況下設置的。 我要做的是像這樣手動放置它:
entity.Navigation(x => x.Cards).AutoInclude();
但我擔心每次新的“腳手架”添加新表時都會被覆蓋。
實體:
public partial class Contract
{
public Contract()
{
Cards = new HashSet<Card>();
}
// ...
public virtual ICollection<Cards> Cards { get; set; }
}
您可以在部分 class 中實現部分方法 OnModelCreatingPartial,因此不會覆蓋任何內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.