在通过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.

其他回答

我今天才遇到这个问题。我有数据存储库类库与EF63 NuGet包和控制台应用程序进行测试,其中只引用类库项目。我创建了一个非常简单的构建后命令,它将EntityFramework.SqlServer.dll从类库的Bin\Debug文件夹复制到控制台应用程序的Bin\Debug文件夹,问题就解决了。不要忘记将entityFramework部分添加到控制台应用程序的.config文件中。

我抛出了相同的异常。我包括

using System.Data; 
using System.Data.Entity;

一切都恢复正常了。

这些对我都没用。我确实在另一个stackoverflow问题中找到了解决方案。我将在这里添加它以方便参考:

你需要做一份参考资料,所以它会在申请中被复制 路径。因为稍后它将在运行时被引用。所以你不需要 需要复制任何文件。

private volatile Type _dependency;

public MyClass()
{
    _dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}

在Azure上从CE db迁移到Sql Server时,我遇到了一个相关的问题。浪费了4个小时来解决这个问题。希望这能挽救一些有类似命运的人。对我来说,我的包中有一个对SqlCE的引用。配置文件。删除它解决了我的整个问题,并允许我使用迁移。太棒了,微软又推出了一项存在不必要的复杂设置和配置问题的技术。

删除bin文件夹帮我解决了这个问题