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

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


当前回答

大家注意,两个dll EntityFramework.dll和EntityFramework.SqlServer.dll是DataAccess层库,在视图或任何其他层中使用它们是不符合逻辑的。它能解决你的问题,但不符合逻辑。

逻辑的方法是删除实体属性并用Fluent API替换它们。这是实解

其他回答

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

另外,确保你的启动项目是包含dbcontext(或相关的app.config)的项目。我的是试图启动一个网站项目,没有所有必要的配置设置。

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.

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

似乎没有人提到首先检查system . data . sqlclient是否安装在系统中,以及是否引用了它。

我通过安装System.Data.SqlClient并在app.Config中添加一个新的提供者来解决我的问题

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>