No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

Entity Framework

Entity Framework Problem Overview

After downloading the EF6 by nuget and try to run my project, it returns the following error:

> No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See for more information.

enter image description here

Entity Framework Solutions

Solution 1 - Entity Framework

I just got into the same problem and it looks like EntityFramework although installed from NuGet Package Manager was not correctly installed in the project.

I managed to fix it by running the following command on Package Manager Console:

PM> Install-Package EntityFramework

Solution 2 - Entity Framework

You've added EF to a class library project. You also need to add it to the project that references it (your console app, website or whatever).

Solution 3 - Entity Framework

You don't need to install Entity Framework in your Console application, you just need to add a reference to the assembly EntityFramework.SqlServer.dll. You can copy this assembly from the Class Library project that uses Entity Framework to a LIB folder and add a reference to it.

In summary:

  • Class Library application:
    • Install Entity Framework
    • Write your data layer code
    • app.config file has all the configuration related to Entity Framework except for the connection string.
  • Create a Console, web or desktop application:
    • Add a reference to the first project.
    • Add a reference to EntityFramework.SqlServer.dll.
    • app.config/web.config has the connection string (remember that the name of the configuration entry has to be the same as the name of the DbContext class.

I hope it helps.

Solution 4 - Entity Framework

You can also see this message if you forget to include "EntityFramework.SqlServer.dll".

It appears to be a newly added file in EF6. Initially I hadn't included it in my merge module and ran into the problem listed here.

Solution 5 - Entity Framework

Instead of adding EntityFramework.SqlServer to host project you can ensure a static reference to it from your Model/entity project like this

static MyContext()
	var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
	if(type == null)
		throw new Exception("Do not remove, ensures static reference to System.Data.Entity.SqlServer");

This will make the build process include the assembly with the host project.

More info on my blog

Solution 6 - Entity Framework

When you install Entity Framework 6 through Nuget. EntityFramework.SqlServer sometime miss for another executable. Simply add the Nuget package to that project.

Sometimes above does not work for Test Project

To solve this issue in Test Project just place this Method inside Test Project:

public void FixEfProviderServicesProblem()
    var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

This method is never been called, but as my observations, the compiler will remove all "unnecessary" assemblies and without using the EntityFramework.SqlServer stuff the test fails.

Solution 7 - Entity Framework

Add this function

private void FixEfProviderServicesProblem()

to database context class in the library class and the missing DLL EntityFramework.SqlServer.dll will be copied to the correct places.

namespace a.b.c
    using System.Data.Entity;

    public partial class WorkflowDBContext : DbContext
        public WorkflowDBContext()
            : base("name=WorkflowDBConnStr")

        public virtual DbSet<WorkflowDefinition> WorkflowDefinitions { get; set; }
        public virtual DbSet<WorkflowInstance> WorkflowInstances { get; set; }
        public virtual DbSet<EngineAlert> EngineAlerts { get; set; }
        public virtual DbSet<AsyncWaitItem> AsyncWaitItems { get; set; }
        public virtual DbSet<TaskItem> TaskItems { get; set; }
        public virtual DbSet<TaskItemLink> TaskItemLinks { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

        private 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 for more information.
            var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;


Solution 8 - Entity Framework

None of these worked for me. I did find the solution in another stackoverflow question. I'll add it here for easy reference:

> You need to make a reference, so it will be copied in den application > path. Because later it will be referenced in runtime. So you don't > need to copy any files.

private volatile Type _dependency;

public MyClass()
    _dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);

Solution 9 - Entity Framework

The startup project that references the project where Entity Framework is being used needs the following two assemblies in it's bin folder:

  • EntityFramework.dll
  • EntityFramework.SqlServer.dll

Adding a <section> to the <configSections> of the .config file on the startup project makes the first assembly available in that bin directory. You can copy this from the .config file of your Entity Framework project:

    <!-- 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" />

To make the second .dll available in the bin folder, although not practical, a manual copy from the bin folder of the Entity Framework project can be made. A better alternative is to add to the Post-Build Events of the Entity Framework project the following lines, which will automate the process:

cd $(ProjectDir)
xcopy /y bin\Debug\EntityFramework.SqlServer.dll ..\{PATH_TO_THE_PROJECT_THAT_NEEDS_THE_DLL}\bin\Debug\

Solution 10 - Entity Framework

I got the same error while using Entity Framework 6 with SQL Server Compact 4.0. The article on MSDN for Entity Framework Providers for EF6 was helpful. Running the respective provider commands as nuget packages at Package Manager Console might solve the problem, as also NuGet packages will automatically add registrations to the config file. I ran PM> Install-Package EntityFramework.SqlServerCompact to solve the problem.

Solution 11 - Entity Framework

When the error happens in tests projects the prettiest solution is to decorate the test class with:


Solution 12 - Entity Framework

Ran into this problem today when working with a set of web services, each in different projects, and a separate project containing integration tests for some of those services.

I've been using this setup for some time with EF5, without needing to include references to EF from the Integration Test Project.

Now, after upgrading to EF6, it seems I need to include a reference to EF6 in the integration test project too, even though it is not used there (pretty much as pointed out above by user3004275).

Indications you're facing the same problem:

  • Calls directly to EF (connecting to a DB, getting data, etc) work fine, as long as they are initiated from a project that has references to EF6.
  • Calls to the service via a published service interface work fine; i.e. there are no missing references "internally" in the service.
  • Calls directly to public methods in the service project, from a project outside the service, will cause this error, even though EF is not used in that project itself; only internally in the called project

The third point is what threw me off for a while, and I'm still not sure why this is required. Adding a ref to EF6 in my Integration Test project solved it in any case...

Solution 13 - Entity Framework

Add below to your app.config.

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameter value="v11.0" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />

Solution 14 - Entity Framework

I just run into this problem today. I have data repository class library with EF63 NuGet package and console application for testing, which have reference only to class library project. I created very simple post-build command, which copies EntityFramework.SqlServer.dll from class library's Bin\Debug folder to console application's Bin\Debug folder and problem solved. Do not forget to add entityFramework section to console application's .config file.

Solution 15 - Entity Framework

I also had a similar problem.My problem was solved by doing the following:

enter image description here

enter image description here

Solution 16 - Entity Framework

You are just missing a reference to EntityFramework.SqlServer.dll. For EntityFramework projects using SQL Server, the two files you need to refer are EntityFramework.SqlServer.dll and EntityFramework.dll

Solution 17 - Entity Framework

Deleting the BIN-Folder did it for me

Solution 18 - Entity Framework

You should force a static reference to the EntityFramework.SqlServer.dll assembly, but instead of putting a dummy code, you can do this in a more beautiful way:

  1. If you already have a DbConfiguration class:

    public class MyConfiguration : DbConfiguration
        public MyConfiguration()
            this.SetProviderServices(System.Data.Entity.SqlServer.SqlProviderServices.ProviderInvariantName, System.Data.Entity.SqlServer.SqlProviderServices.Instance);
  2. If you don't have a DbConfiguration class you must put the following code at app startup (before EF is used):

    static MyContext()
        DbConfiguration.Loaded += (sender, e) =>
            e.ReplaceService<DbProviderServices>((s, k) => System.Data.Entity.SqlServer.SqlProviderServices.Instance);

Solution 19 - Entity Framework

just Copy EntityFramework.SqlServer.dll into bin folder

Solution 20 - Entity Framework

I have just re-installed the Entity Framework using Nuget. And follow the instruction written on the link below :

I think the problem will get solved.

Solution 21 - Entity Framework

Expand YourModel.edmx file and open YourModel.Context.cs class under

I added the following line in the using section and the error was fixed for me.

using SqlProviderServices = System.Data.Entity.SqlServer.SqlProviderServices;

You may have to add this line to the file each time the file is auto generated.

Solution 22 - Entity Framework

I have the same error. It's weird that it only happens whenever I used my dbContext to query to any of my model or get its list like:

var results = _dbContext.MyModel.ToList();

We tried to reinstall the Entity Framework, reference it properly but to no avail.

Luckily, we tried to check the Nuget for ALL solutions, then update everything or make sure everything is the same version because we noticed that the two projects has different EF versions on the Web project. And it works. The error is gone.

Here is the screenshot on how to Manage Nuget for all solutions:

enter image description here

Solution 23 - Entity Framework

Just Install EntityFramework package to your Web/Console Project. That should add the section to your config file.

Solution 24 - Entity Framework

it looks like nobody mentioned first checking if System.Data.SqlClient is installed in the system and if a reference is made to it.

i solved my issue by installing System.Data.SqlClient and adding in a new provider in app.Config

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>

Solution 25 - Entity Framework

Also, make sure you startup project is the project that contains your dbcontext (or relevant app.config). Mine was trying to start up a website project which didnt have all the necessary configuration settings.

Solution 26 - Entity Framework

I tried almost all the above and nothing worked.

Only when I set the referenced DLLs in the Default Project EntityFramework and EntityFramework.SqlServer properties Copy Local to True did it start working!

Solution 27 - Entity Framework

everybody I need your Attention that two dll EntityFramework.dll And EntityFramework.SqlServer.dll are DataAccess layer Library And it is not Logical to Use them in view or any other solves your problem but it is not logical.

logical way is that enitiess attribute remove and replace them with Fluent API.this is real solution

Solution 28 - Entity Framework

I had one console application and class library. In class library I created Entity Data Model (right click to Class Library > Add > New Item > Data > ADO.NET Entity Data Model 6.0) and put reference inside console application. So, you have console application which has reference to class library and inside class library you have EF model. I had the same error when I tried to get some records from the table.

I resolved this issue by following these steps:

  1. Right click to solution and choose option 'Manage NuGet Packages for Solution' and NuGet package manager window will show up.
  2. Go to 'Manage' option under 'Installed packages' TIP: Entity Framework is added to Class Library, so you will have EntityFramework under 'Installed packages' and you'll see 'Manage'option
  3. Click on 'Manage' option and check to install package to project which has reference to class library which holds EF model (in my case I set check box to install package to console app which had reference to class library which had EF model inside)

That's all I had to do and everything worked perfect.

I hope it helped.

Solution 29 - Entity Framework

I have the same issue(in my 3-Tire level project) and I fixed it by adding/installing the EF to my main Project.

Solution 30 - Entity Framework

I had a related issue when migrating from a CE db over to Sql Server on Azure. Just wasted 4 hrs trying to solve this. Hopefully this may save someone a similar fate. For me, I had a reference to SqlCE in my packages.config file. Removing it solved my entire issue and allowed me to use migrations. Yay Microsoft for another tech with unnecessarily complex setup and config issues.

Solution 31 - Entity Framework

I had the same issue, just copied the App Config file from the project that contained the DBContext to my test project

Solution 32 - Entity Framework

I had the identical exception thrown. I included

using System.Data; 
using System.Data.Entity;

and everything is back to working again ..

Solution 33 - Entity Framework

As message shows that we need to add provider System.Data.SqlClient that's why we need to install nuget package of EntityFramework that has two dll but if we are developing only console application then we just need to add reference of EntityFramework.SqlServer.dll

Solution 34 - Entity Framework

Note: I had this problem while Generating Database Sql from Model. It had created all the tables fine but wouldn't export the changes. What you need to notice is that this error is generated when you try to export the sql using the DDL Generation Template as SSDLtoSQL10. It is expecting MySQL connection here so make sure you select from the drop down DDL Generation Template SSDLtoMySQL on the Model properties. Spent a whole day on this !

Solution 35 - Entity Framework

In my case, everything was working properly then suddenly stopped worked because I think Resharper altered some changes which caused the problem. My project was divided into the data layer, service and presentation layer. I had Entity framework installed and referenced in my data layer but still the error didn't go away. Uninstalling and reinstalling didn't work either. Finally, I solved it by making the data layer the Startup project, making migration, updating the database and changing the Startup project back to my presentation layer.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFernando VellozoView Question on Stackoverflow
Solution 1 - Entity FrameworkdouglaslpsView Answer on Stackoverflow
Solution 2 - Entity FrameworkClément PicouView Answer on Stackoverflow
Solution 3 - Entity FrameworkFrancisco GoldensteinView Answer on Stackoverflow
Solution 4 - Entity FrameworkMikeView Answer on Stackoverflow
Solution 5 - Entity FrameworkAndersView Answer on Stackoverflow
Solution 6 - Entity FrameworkUmar AbbasView Answer on Stackoverflow
Solution 7 - Entity FrameworkJohannesView Answer on Stackoverflow
Solution 8 - Entity FrameworkCarraView Answer on Stackoverflow
Solution 9 - Entity FrameworkLeonel B.View Answer on Stackoverflow
Solution 10 - Entity FrameworkMaySaraView Answer on Stackoverflow
Solution 11 - Entity FrameworkAlberto JuanView Answer on Stackoverflow
Solution 12 - Entity FrameworkKjartanView Answer on Stackoverflow
Solution 13 - Entity FrameworkTaranView Answer on Stackoverflow
Solution 14 - Entity FrameworkOndřejView Answer on Stackoverflow
Solution 15 - Entity FrameworkBehrouzMoslemView Answer on Stackoverflow
Solution 16 - Entity Frameworkuser2956314View Answer on Stackoverflow
Solution 17 - Entity FrameworkDavidView Answer on Stackoverflow
Solution 18 - Entity FrameworkRosberg LinharesView Answer on Stackoverflow
Solution 19 - Entity FrameworkyaserjalilianView Answer on Stackoverflow
Solution 20 - Entity FrameworkKuntal GhoshView Answer on Stackoverflow
Solution 21 - Entity Frameworkuser2347528View Answer on Stackoverflow
Solution 22 - Entity FrameworkWilly David JrView Answer on Stackoverflow
Solution 23 - Entity FrameworkVijaya MallaView Answer on Stackoverflow
Solution 24 - Entity FrameworkTobi OwolawiView Answer on Stackoverflow
Solution 25 - Entity Frameworkuser2588362View Answer on Stackoverflow
Solution 26 - Entity FrameworkSharpCView Answer on Stackoverflow
Solution 27 - Entity FrameworkVahid AkbariView Answer on Stackoverflow
Solution 28 - Entity FrameworkdkeroView Answer on Stackoverflow
Solution 29 - Entity FrameworkmszView Answer on Stackoverflow
Solution 30 - Entity Frameworkuser2662643View Answer on Stackoverflow
Solution 31 - Entity Frameworkstephen ebichondoView Answer on Stackoverflow
Solution 32 - Entity FrameworkkneerunjunView Answer on Stackoverflow
Solution 33 - Entity FrameworkSandeep ShekhawatView Answer on Stackoverflow
Solution 34 - Entity FrameworkExcalibur2000View Answer on Stackoverflow
Solution 35 - Entity FrameworkAlf MohView Answer on Stackoverflow