简体   繁体   中英

No Entity Framework provider found for the ADO.NET provider

I've been trying to insert some data into northwind using WCF. I can't figure out why the provider isn't found.

The service has EF6 installed.

Here's the snippet of my config file:

<?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>
  <connectionStrings>
    <add name="northwindEntities" connectionString="metadata=res://*/NorthwindModel.csdl|res://*/NorthwindModel.ssdl|res://*/NorthwindModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=northwind;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="OrdersEndPoint" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8080/OrdersHelper" binding="basicHttpBinding" bindingConfiguration="OrdersEndPoint" contract="ServiceReference.IOrdersHelper" name="OrdersEndPoint" />
    </client>
  </system.serviceModel>
  <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>
</configuration>

DBContext Class:

public partial class northwindEntities : DbContext
    {
        public northwindEntities()
            : base("name=northwindEntities")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }

Followed by Entity Properties and Stored Procedures

Can't believe I hadn't seen it any sooner... I had different EF versions installed on my service and consumer. Problem solved.

Here is your Web.config file

   <?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>  
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="OrdersEndPoint" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:8080/OrdersHelper" binding="basicHttpBinding" bindingConfiguration="OrdersEndPoint" contract="ServiceReference.IOrdersHelper" name="OrdersEndPoint" />
        </client>
      </system.serviceModel>
      <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>


    <connectionStrings>
        <add name="northwindEntities" connectionString="metadata=res://*/NorthwindModel.csdl|res://*/NorthwindModel.ssdl|res://*/NorthwindModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=northwind;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>


    </configuration>

And Your DbContext Class should be as below

public partial class northwindEntities : DbContext
    {
        public northwindEntities()
            : base("northwindEntities")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM