在通过nuget下载EF6并尝试运行我的项目后,它返回以下错误:
没有为ADO找到实体框架提供程序。NET提供程序,使用不变名称'System.Data.SqlClient'。确保提供者在应用程序配置文件的“entityFramework”部分中注册。更多信息请参见http://go.microsoft.com/fwlink/?LinkId=260882。
在通过nuget下载EF6并尝试运行我的项目后,它返回以下错误:
没有为ADO找到实体框架提供程序。NET提供程序,使用不变名称'System.Data.SqlClient'。确保提供者在应用程序配置文件的“entityFramework”部分中注册。更多信息请参见http://go.microsoft.com/fwlink/?LinkId=260882。
当前回答
大家注意,两个dll EntityFramework.dll和EntityFramework.SqlServer.dll是DataAccess层库,在视图或任何其他层中使用它们是不符合逻辑的。它能解决你的问题,但不符合逻辑。
逻辑的方法是删除实体属性并用Fluent API替换它们。这是实解
其他回答
我刚刚遇到了同样的问题,它看起来像EntityFramework,虽然从NuGet包管理器安装没有正确安装在项目中。
我设法通过在包管理器控制台运行以下命令来修复它:
PM> Install-Package EntityFramework
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.
大家注意,两个dll EntityFramework.dll和EntityFramework.SqlServer.dll是DataAccess层库,在视图或任何其他层中使用它们是不符合逻辑的。它能解决你的问题,但不符合逻辑。
逻辑的方法是删除实体属性并用Fluent API替换它们。这是实解
如果你忘记包含"EntityFramework.SqlServer.dll",你也可以看到这个消息。
它似乎是EF6中新添加的文件。最初我没有将它包含在合并模块中,遇到了这里列出的问题。
我有同样的错误。奇怪的是,它只发生在我使用dbContext查询我的任何模型或获得它的列表时:
var results = _dbContext.MyModel.ToList();
我们试图重新安装实体框架,正确引用它,但无济于事。
幸运的是,我们尝试检查Nuget的所有解决方案,然后更新所有内容或确保所有内容都是相同的版本,因为我们注意到两个项目在Web项目上有不同的EF版本。这很有效。错误消失了。
以下是关于如何管理所有解决方案的Nuget的截图: