Entity Framework works on Local Server but not Remote

asp.net entity-framework


Ok so I have a website that uses ASP.net mvc, the problem I am having is with Entity Framework. I added all the references and got it to run on my local machine but when I publish it I get the following error.

System.InvalidOperationException: 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. Make sure the provider assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

I have double checked my references and I have EntityFramework.SqlServer and System.Data both added into my project. The connection string I use to connect to the data base and declare the service provide is below.

<add name="[dataConnection]" connectionString="Data Source=[ip of host machine];Database=[name];UID=[user];pwd=*******;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />

Name we just have the name of the data base, this is also used in my web.debug.config

<add name="[dataconnection]"
  connectionString="Data Source=.;Database=[name];UID=[user];pwd=*******;MultipleActiveResultSets=True;"
  xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

I am pretty new to this entire thing and was just handed someone elses code so I am trying to learn on the flow. This is my first encounter with this so any direction would be appreciated.

12/4/2012 9:01:02 PM

Accepted Answer

I had the same problem in my integration test assembly (i'm using ms visual studio unit testing framework for this) and i've solved it by adding EF assemblies to deployment items in .testsettings file.

  1. I've installed EF 6 alpha using Package Manager Console using: Install-Package EntityFramework -Pre

Here is my app.config

    <?xml version="1.0" encoding="utf-8"?>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />

My connection string (i'm setting it in code): server=.\SIN;initial catalog=IntegrationTests;User ID=user;Password=pass;MultipleActiveResultSets=true;

  1. I've looked at the EF assembly reference properties to see if they are set to "Copy Local" = True. And finally i've checked out TestResults/../Out folder and found that there is no EntityFramework.SqlServer assembly there (SqlProviderServices class resides in it).

  2. So i've just added both EF 6 assemblies to my deployment items and now everything is ok deployment items

You can try to copy EntityFramework.SqlServer assembly to your web server directory to see if it works.

Maybe this link can be helpful


Make sure you don't have a reference to System.Data.Entity, because you'll be using one from GAC. EF 6 Alpha assemblies is not installed in GAC when you install them with Nuget. Target framework should be .NET 4.5.

Sorry for my bad english.

12/8/2012 11:05:13 PM

Popular Answer

A question: which EF version?

Check your IIS pool .NET version... It should be the one that points to the .NET version of your published project... The assembly of EF should be in the .NET framework folder under Windows directory (AKA GAC)

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