現象:
The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application.
引用: 高人dudu 的回復
這是一個誤導人的錯誤信息,實際是因為找不到 EntityFramework.SqlServer.dll 文件。
問題背景是web項目所引用的項目中安裝了EF的nuget包,而web項目本身沒有安裝。於是build后,web項目的bin文件夾中只有EntityFramework.dll,卻沒有EntityFramework.SqlServer.dll。
解決方法:web項目也安裝Entity Framework的nuget包。
把所引用的項目中安裝了EF的nuget包的bin目錄下的EntityFramework.SqlServer.dll 文件復制到Web項目中的bin目錄下