ASP. NET MVC4 & amp; Entity Framework 6.0 IIS deployment error solution, ASP. NETMVC4

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.