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

后端 未结 13 2275
[愿得一人]
[愿得一人] 2020-12-08 04:18

I recently upgraded/updated Entity Framework in an old project from version 4 or 5 to version 6. Now I get this exception:

An exception of type \'Syst

相关标签:
13条回答
  • 2020-12-08 04:49

    What worked for me was downgrading from EF 6.1.3 to EF 6.1.1.

    In Visual Studios 2012+ head over to:

    Tools - Nuget Package Manager - Package Manager Console`

    Then enter:

    Install-Package EntityFramework.SqlServerCompact -Version 6.1.1

    I did not have to uninstall EF 6.1.3 first because the command above already does that.

    In addition, I don't know if it did something, but I also installed SQL Server CE in my project.

    Here's the link to the solution I found:

    http://www.itorian.com/2014/11/no-entity-framework-provider-found-for.html

    0 讨论(0)
  • Install Entity Framework in each project (Ex: In Web, In Class Libraries) from NuGet Package Manager orelse Open Tools - Nuget Package Manager - Package Manager Console and use Install-Package EntityFramework to install the Entity Framework.

    Don't need to add the below code in every config file. By default it will be added in the project where the database is called through Entity Framework.

    <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework>

    0 讨论(0)
  • 2020-12-08 04:50

    I have the same problem, the difference is I don't have access to the source code. I've fixed my problem by putting correct version of EntityFramework.SqlServer.dll in the bin directory of the application.

    0 讨论(0)
  • 2020-12-08 04:50

    I also had a similar problem

    My problem was solved by doing the following:

    0 讨论(0)
  • 2020-12-08 05:01

    I have solved the issue using below code in my DBContext

     
    public partial class Q4Sandbox : DbContext
        {
            public Q4Sandbox()
                : base("name=Q4Sandbox")
            {
            }
    
            public virtual DbSet Employees { get; set; }
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {           
               var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
            }
        }
    

    Thanks to a SO member.

    0 讨论(0)
  • 2020-12-08 05:01

    Add "EntityFramework.SqlServer.dll" into your bin folder. Problem will get resolved.

    0 讨论(0)
提交回复
热议问题