实体框架6:找不到ADO.NET的实体框架提供程序

时间:2019-03-03 17:26:21

标签: c# entity-framework-6

我收到此错误:

  

未找到具有不变名称'System.Data.SqlClient'的ADO.NET提供程序的实体框架提供程序。确保提供程序已在应用程序配置文件的“ entityFramework”部分中注册。

但是<entityFramework>文件中有一个app.config部分。

我的上下文类:

public class NorthwindContext:DbContext
{
    public NorthwindContext():base(nameOrConnectionString:"NorthwindContext") 
    {
    }

    public DbSet<Product> Products { get; set; }
    public DbSet<Category> Categories { get; set; }
}

我的app.config文件:

<?xml version="1.0" encoding="utf-8"?>
<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.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="NorthwindContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=Northwind;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

我该如何解决?有人有主意吗?

0 个答案:

没有答案