EF:No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'.
错误内容:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

解决:
运行需要EntityFramework.SqlServer.dll 以及 EntityFramework.dll;
使用Nuget安装EF后,EF相应的dll存放在packages文件夹中,右键引用进项目:
PM> Install-Package EntityFramework –Version 6.0.0

设置为复制本地:

另外:需要配置提供程序 , 如果从nuget安装则会自动加上配置

再次生成,还是报同样的错误,浏览项目文件夹,发现安装了ef所在项目的bin目录中有EntityFramework.SqlServer.dll,但是主程序的bin目录中只有EntityFramework.dll。
于是将EntityFramework.SqlServer.dll也复制到主程序bin目录中,运行成功。

浙公网安备 33010602011771号