在通过nuget下载EF6并尝试运行我的项目后,它返回以下错误:

没有为ADO找到实体框架提供程序。NET提供程序,使用不变名称'System.Data.SqlClient'。确保提供者在应用程序配置文件的“entityFramework”部分中注册。更多信息请参见http://go.microsoft.com/fwlink/?LinkId=260882。


当前回答

In my case, everything was working properly then suddenly stopped worked because I think Resharper altered some changes which caused the problem. My project was divided into the data layer, service and presentation layer. I had Entity framework installed and referenced in my data layer but still the error didn't go away. Uninstalling and reinstalling didn't work either. Finally, I solved it by making the data layer the Startup project, making migration, updating the database and changing the Startup project back to my presentation layer.

其他回答

我刚刚遇到了同样的问题,它看起来像EntityFramework,虽然从NuGet包管理器安装没有正确安装在项目中。

我设法通过在包管理器控制台运行以下命令来修复它:

PM> Install-Package EntityFramework

YourModel扩张。然后打开YourModel.Context.tt下的YourModel.Context.cs类。

我在使用部分添加了以下一行,错误为我修复了。

使用 SqlProviderServices = System.Data.Entity.SqlServer.SqlProviderServices;

您可能必须在每次自动生成文件时将这一行添加到文件中。

只需安装EntityFramework包到您的Web/控制台项目。这应该会将该节添加到配置文件中。

我有同样的问题,只是复制了应用程序配置文件从包含DBContext的项目到我的测试项目

如果你忘记包含"EntityFramework.SqlServer.dll",你也可以看到这个消息。

它似乎是EF6中新添加的文件。最初我没有将它包含在合并模块中,遇到了这里列出的问题。