EF 6中缺少QueryableExtensions [英] Missing QueryableExtensions in EF 6

查看:187
本文介绍了EF 6中缺少QueryableExtensions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法调用新的 QueryableExtensions ToListAsync ForEachAsync ,...)与EntityFramework 6一起提供。但是我可以调用其他对象(包括相交

I can't call the new QueryableExtensions (ToListAsync, ForEachAsync,...) provided with EntityFramework 6. But i can call others (Include, Intersect).

我引用了 System.Data.Entity
因此,显然,我有一个 System.Data.Entity 的旧版本,以及最新版本的EntityFramework。

I've a reference to System.Data.Entity. So apparently, i've an older version of System.Data.Entity, with the latest version of EntityFramework. Is it possible?

我的代码无法编译,并且在对象浏览器中看不到 ForEachAsync 方法。

My code does not compile and I cannot see the ForEachAsync method in the object browser.

我正在使用Visual Studio 2013,.Net 4.5,EntityFramework 6.1.3,Wpf。

I'm working with Visual Studio 2013, .Net 4.5, EntityFramework 6.1.3, Wpf.

编辑

已安装实体框架:

Entity framework is installed :

我已尝试多次卸载然后重新安装软件包,并重新启动Visual Studio。仍然不起作用

I've tried to Uninstall then Reinstall package many times, with a restart of visual studio. Still not working

编辑

在另一个项目中(此项目引用) ,我可以在对象浏览器中看到 IQueryableExtensions 。如果我将此项目添加到解决方案中(之前只是参考),则对象浏览器中缺少所需的 IQueryableExtensions

In another project (referenced by this one), I can see the IQueryableExtensions needed in the object browser. If I add this project to my solution (before it was only a reference), the IQueryableExtensions needed are missing in the object browser.

推荐答案

您的一个项目可能针对的是.net框架的较早版本。

One of your projects is probably targeting an older version of the .net framework.

我遇到了这个问题当项目的目标是.Net v4.0时,请将其更新为4.5或更高版本。
之后,我还运行了其他人推荐的命令。

I had this issue when a project was targeting .Net v4.0, update it to 4.5 or newer. I also ran the command that others recommended after this.

update-package -reinstall EntityFramework 

在程序包控制台中运行update-package命令时,可以看到.Net的目标版本。例如,我的项目定位到4.0时的输出

You can see what version of .Net is is targeting when you run the update-package command in the package console. For example output from my project when it was targeting 4.0

PM> Update-Package –reinstall EntityFramework
Attempting to gather dependencies information for multiple packages with respect to project '[My project]', targeting '.NETFramework,Version=v4.0'

,然后使用v4.5.2:

and then with v4.5.2:

PM> Update-Package –reinstall EntityFramework
Attempting to gather dependencies information for multiple packages with respect to project '[My Project]', targeting '.NETFramework,Version=v4.5.2'

您通过以下方式更新.net版本:

You update your .net version by:

right clicking on the project in the solution explorer, 
choosing "Properties"
on the Application Tab (default) from the DropDown list labeled "Target Framework" select 4.5 (or greater - I chose 4.5.2)

有可能您不需要重新安装软件包,但是我在检查是否重新安装之前它起作用了。

There is a chance you don't need to reinstall the package, however I reinstalled before checking if it worked.

这篇关于EF 6中缺少QueryableExtensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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