实体框架核心不包含“包含"的定义 [英] Entity Framework Core does not contain a definition for 'Include'

查看:70
本文介绍了实体框架核心不包含“包含"的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Entity Framework Core 1.0,并尝试通过dbcontext填充对象时使用.include.

I am trying to work with Entity Framework Core 1.0 and trying to utilize the .Include when filling objects through the dbcontext.

        EFTestContext context = new EFTestContext();
        var testEntity = context.TestEntity
            .Include(t => t.TestEntity2)
            .ToList();

它给我错误

不包含包含"的定义,找不到扩展方法包含",接受第一个类型为"DbSet"的参数

does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'DbSet' could be found

到目前为止,我在Stackoverflow中发现的唯一类似的东西是

The only similar thing I found so far in Stackoverflow is

IQueryable<不包含包含"的定义,也没有扩展方法包含"

但是添加using语句

But adding the using statement

using System.Data.Entity;

只要给我错误

名称空间"System.Data"中不存在类型或名称空间名称"Entity"(您是否缺少程序集引用?)

The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

有人知道我需要什么才能包含WF Core 1.0出现吗?

Anyone know what I need to get the Include to show up with WF Core 1.0?

推荐答案

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆