我无法调用EntityFramework 6随附的新QueryableExtensions
(ToListAsync
,ForEachAsync
...)。但是我可以调用其他(Include
,Intersect
)。
我有个参考System.Data.Entity
。因此,显然,我有的较旧System.Data.Entity
版本和EntityFramework的最新版本。可能吗?
我的代码无法编译,并且无法ForEachAsync
在对象浏览器中看到该方法。
我正在使用Visual Studio 2013,.Net 4.5,EntityFramework 6.1.3,Wpf。
编辑
我尝试过多次卸载然后重新安装软件包,并重新启动了Visual Studio。还是行不通
编辑
在另一个项目(此项目引用)中,我可以IQueryableExtensions
在对象浏览器中看到所需的项目。如果我将此项目添加到解决方案中(之前只是参考),IQueryableExtensions
则对象浏览器中缺少所需的项目。
您的一个项目可能针对的是.net框架的较旧版本。
当一个项目面向.Net v4.0时,我遇到了这个问题,将其更新为4.5或更高版本。此后,我还运行了其他人推荐的命令。
update-package -reinstall EntityFramework
在程序包控制台中运行update-package命令时,可以看到目标是.Net的版本。例如,我的项目定位到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:
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版本:
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)
您可能不需要重新安装该软件包,但是在检查它是否有效之前,我已经重新安装了该软件包。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句