EntityFramework Core 1.1.0缺少Include()?

bir*_*win 6 c# entity-framework entity-framework-core

我正在使用EntityFramework Core 1.1.0.我可以查询表并加载实体,但Microsoft的指示表明我是否要加载关系数据,我应该使用以下.Include()函数:

https://docs.microsoft.com/en-us/ef/core/querying/related-data

您可以使用该Include方法指定要包含在查询结果中的相关数据.在以下示例中,结果中返回的博客将Posts使用相关帖子填充其属性.

using (var context = new BloggingContext())
{
    var blogs = context.Blogs
        .Include(blog => blog.Posts)
        .ToList();
}
Run Code Online (Sandbox Code Playgroud)

我别无选择.Include().

任何想法为什么缺少或如何加载外键关系数据?

this.context.Mail
    .Include("Files") // This is missing
Run Code Online (Sandbox Code Playgroud)

我已经使用显式加载关系数据.这适用于小型结果集,但随着我的数据集的增长,这将使我感到悲伤.

var mails = this.context.Mail.ToList();
mails.ForEach(mail =>
{
    this.context.Entry(mail)              
    .Collection(m => m.Files)
    .Load();
});
Run Code Online (Sandbox Code Playgroud)

Chr*_*rdt 23

你是否包含了正确的命名空间?

从文档中链接的存储库:

using Microsoft.EntityFrameworkCore;
using System.Linq;
Run Code Online (Sandbox Code Playgroud)