ASP. NET MVC4 & Entity Framework 6.0 IIS deployment error solution, ASP. NETMVC4
Recently, when I learned about MVC4, I made a simple small project and used Entity Framework as the Model. It was okay when F5 started debugging and running, but an error was reported when it was accessed after being published to IIS.
The error message is as follows:
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.
It's strange. After searching, find a foreigner's post and stamp it here.
The solution is as follows:
Add this method to the context code CS file (Model1.Context. cs) of EF
public void FixEfProviderServicesProblem(){//The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer'//for the 'System.Data.SqlClient' ADO.NET provider could not be loaded. //Make sure the provider assembly is available to the running application. //See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;}
The specific reason is unclear. This method has never been called,... Easy to use!
This solution also requires subsequent observation. After all, the modification is based on the files generated by the database.
There is another solution I have not tried. You can forcibly deploy the EntityFramework. SqlServer. dll file to the output directory. If you are interested, try it.