EF 6中缺少QueryableExtensions

编程入门 行业动态 更新时间:2024-10-20 05:34:47
本文介绍了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.

推荐答案

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

One of your projects is probably targeting an older version of the 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'

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

You update your 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

本文发布于:2023-11-08 13:54:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EF   QueryableExtensions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!