C# 命名空间“System.Data”中不存在类型或命名空间名称“实体”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9972426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The type or namespace name 'Entity' does not exist in the namespace 'System.Data'
提问by st mnmn
I'm using WS class and it gave me error when I run the application:
我正在使用 WS 类,当我运行应用程序时它给了我错误:
The type or namespace name 'Entity' does not exist in the namespace 'System.Data'
I have a reference to the System.Data;and to System.Data.Entity;But no changes. I keep getting the error. I have also in the web.config the line:
我有参考System.Data;和 ,System.Data.Entity;但没有变化。我不断收到错误。我也在 web.config 行:
<compilation debug ="true" targetFramework="4.0"/>
采纳答案by st mnmn
Thanks every body!
I found the solution. not that I understand why but I tried this and it worked!
I just had to add a reference to: System.Data.Entity.Designand don't have to write any usingin the code.
Thanks!
谢谢大家!我找到了解决方案。不是我明白为什么,但我试过这个并且它起作用了!我只需要添加对:的引用,System.Data.Entity.Design而不必using在代码中写入任何内容。谢谢!
回答by AlanMorton2.0
Hi this post is very misleading, if your reading this 2 years on.
嗨,这篇文章是非常具有误导性的,如果你读了 2 年。
With using EF6 and .net 4.5.1 in VS 2013 I have had to reference the following to get this to work
在 VS 2013 中使用 EF6 和 .net 4.5.1 时,我必须参考以下内容才能使其正常工作
using System.Data.Entity.Core.EntityClient;
a little different to before,
和以前有点不一样
this is more of a FYI for people that come here for help on newer problems than a answer to the original question
对于来这里寻求新问题帮助的人来说,这更像是一个仅供参考,而不是原始问题的答案
回答by Tony Ding
Right-click on the Solution from the Visual Studio Solution Explorer click the Manage Nuget packages for solution and install the EntityFramework
右键单击 Visual Studio 解决方案资源管理器中的解决方案,单击管理解决方案的 Nuget 包并安装 EntityFramework
回答by Cormac Hallinan
I just had the same error with Visual Studio 2013 and EF6. I had to use a NewGet packed Entity Framework and done the job perfectly
我只是在 Visual Studio 2013 和 EF6 上遇到了同样的错误。我不得不使用 NewGet 打包的实体框架并完美地完成了这项工作
回答by Bikash Kumar
I had just updated my Entity framework to version 6 in my Visual studio 2013 through NugetPackage and add following References:
我刚刚通过 NugetPackage 在我的 Visual Studio 2013 中将我的实体框架更新到版本 6 并添加以下参考:
System.Data.Entity,
System.Data.Entity.Design,
System.Data.Linq
by right clicking on references->Add references in my project. Now delete my previously created Entity model and recreate it again,Built solution. Now It works fine for me.
通过右键单击引用-> 在我的项目中添加引用。现在删除我之前创建的实体模型并重新创建它,构建解决方案。现在它对我来说很好用。
回答by Joe
tried reinstall - no luck. i had to refresh a table in my model before it would find Entity.
尝试重新安装 - 没有运气。在找到实体之前,我必须刷新模型中的表格。
回答by TJPrgmr
I had entity framework 6.1.3, upgraded (well, more downgraded in NuGet) to 6.1.2. Worked.
我有实体框架 6.1.3,升级(好吧,在 NuGet 中降级更多)到 6.1.2。工作了。
回答by GigiSan
I will add my answer to cover all cases:
我将添加我的答案以涵盖所有情况:
My solution was unistalling EntityFramework from NuGet Package Manager and then I was prompted to restart Visual Studio because it couldn't "finalize the uninstall".
我的解决方案是从 NuGet 包管理器卸载 EntityFramework,然后提示我重新启动 Visual Studio,因为它无法“完成卸载”。
I restarted Visual Studio and reinstalled EntityFramework then my problem was solved.
我重新启动了 Visual Studio 并重新安装了 EntityFramework,然后我的问题就解决了。
Hope this helps someone!
希望这可以帮助某人!
回答by Rajesh Kumar Swain
You need to install Entity framework by right click on your VS solution and click Manage NuGet Package solution and search there Entity framework. After installation the issue will be solved
您需要通过右键单击您的 VS 解决方案并单击管理 NuGet 包解决方案并在那里搜索实体框架来安装实体框架。安装后问题就解决了
回答by Roberto Gata
It's helped me, I uninstalled EF, restarted VS and I added 'using':
它对我有帮助,我卸载了 EF,重新启动了 VS 并添加了“使用”:
using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;

