Can't find System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer

c# entity-framework-6


I'm constructing a DbContext from an SqlConnection. When I use it, I receive the following error:

The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' for the 'System.Data.SqlClient' ADO.NET provider could not be loaded.

I'm using 6.0.0-alpha2-11210.

I found that weird since I have a reference toward Entity.SqlServer and that I managed to 'fix it' by putting the following line of code before a query:

var patch_only = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

Is it a bug of the alpha version?

1/13/2015 12:33:04 PM

Accepted Answer

I hope I am not late. I am using ASP.NET MVC 4 and Entity Framework 6 alpha 3 and ran into a similar problem.

I have multiple projects in my solution. The 2 main projects are:


In the first project I would set up all my repositories, DbContext, etc etc. In this project I have 2 references:


The second project is my website. It uses the repositories in the first project to return my data. For example:

private readonly IMyRepository myRepository;

public MyController(IMyRepository myRepository)
     this.myRepository = myRepository;

public ActionResult Details(int id)
     MyObject myObject = myRepository.FindById(id);

     return View();

This is where I had my issues, calling FindById.

All that I did was to add the following reference to my website:


In my web.config:

<!-- For more information on Entity Framework configuration, visit -->
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

And beneath the closing system.webServer tag:

     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
               <parameter value="v11.0" />

I hope this will help.

3/26/2013 6:06:59 PM

Popular Answer

What you did creates a reference to EntityFramework.SqlServer.dll. It ensures that this assembly gets copied over to the bin folder of projects using you data access assembly.

You can do the same by adding something like the following somewhere in your data access assembly:

Type _Hack = typeof(System.Data.Entity.SqlServer.SqlProviderServices)

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow