我在C#一個奇怪的行爲與EF 這是一個與EF核心.NET核心項目1.1.0在實體框架的核心沒有嵌套結果
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
我已經創建了兩個模型,「用戶」和「Group」
public class User
{
public int Id { get; set; }
public string name { get; set; }
public string lastName { get; set; }
public List<Group> Groups { get; set; }
}
public class Group
{
public int Id { get; set; }
public string groupName { get; set; }
public virtual User User { get; set; }
}
結果schould給我一個用戶列表他的組。
現在奇怪的部分:
結果來自DB回來,我看着ALLUSER,組是空
我看看到上下文看組
組充滿:
現在我又把眼光投向ALLUSER結果和神奇 在GR在每個用戶項目內填充oup。
組是內部填充用戶:
我非常感謝所有幫助!
實體框架核心沒有延遲加載。例如LazyLoadingEnabled將不可用。更多信息:https://docs.microsoft.com/en-us/ef/core/querying/related-data(EF Core尚不能使用延遲加載。) – Ben
是的,它適用於.Include,謝謝。所有這麼多! – KroKro