Entity Framework ADO.NET Sql.Data.Client provider not found

后端 未结 9 2223
天涯浪人
天涯浪人 2020-12-10 11:36

I have a similar problem as the one presented in the question No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'

相关标签:
9条回答
  • 2020-12-10 12:16

    If you get this error on Visual Studio while debugging, this happens after you installed another DB provider or IDE with DB Provider. I faced this error after I installed Delphi on my computer.

    Solution: Just edit C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config and remove tags.

    0 讨论(0)
  • 2020-12-10 12:17

    Wow...that is pretty special...Anyways. You need to register the Entity Framework provider for the System.Data.SqlClient SQL connection type.

    You want to add the following to your app.config/web.config

    <configuration>
      <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="System.Data.SqlClient" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>
    
    0 讨论(0)
  • 2020-12-10 12:18

    Simply install "MySql.Data.Entity" from nuget! It will install mysql ado driver and entity driver automatically!

    0 讨论(0)
  • 2020-12-10 12:19

    I got this error but for me it was something entirely different.

    I had to edit:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
    

    And:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
    

    Searching for DbProviderFactories both configs looked like this:

    <system.data>
        <DbProviderFactories>
            <add name="IBM DB2 for i .NET Provider" invariant="IBM.Data.DB2.iSeries" description=".NET Framework Data Provider for IBM i" type="IBM.Data.DB2.iSeries.iDB2Factory, IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26" />
        </DbProviderFactories>
        <DbProviderFactories />
    </system.data>
    

    When I removed the trailing <DbProviderFactories /> everything started working again.

    I was able to solve it by looking at only Unable to find the requested .Net Framework Data Provider and finding this answer:

    https://stackoverflow.com/a/9929534/3850405

    0 讨论(0)
  • 2020-12-10 12:27

    Try adding

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

    in the ctor of your designContext.

    0 讨论(0)
  • 2020-12-10 12:29

    Still not sure what was causing the problem, but ended up creating a new solution and copying everything from my project. Now works fine. Really weird, indeed.

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