简体   繁体   中英

No Entity Framework provider found … with invariant name 'System.Data.SqlClient'

None of the posts on here has seemed to address this specific version of my error but I may just be missing something...

Situation:

MVC website consumes a WCF service. Data is saved in the WCF service. Both are running

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

Both have connection string:

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

Site runs until I actually try to save to the database in the WCF service using (errors on second line)...

SiteTrackerEntities db = new SiteTrackerEntities();
db.Entry(visitorData).State = System.Data.Entity.EntityState.Added; 

I then get this lovely error:

VisitorInformation.ssdl(2,2) : error 0152: 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 http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
  • Made sure that both are using the same version of EF (6.0). Check.
  • Tried to enter the provider name in the connection string but already using providerName="System.Data.EntityClient"
  • Tried removing and reinstalling EF using PM console. Check.
  • Manually removed Ef references and readded them. Check.
  • WCF Service has reference to Entity.Framework.SqlServer (version 6.0.0.0). Check.
  • MVC application has connection string to the database that is only used in the WCF service (odd that it needs it but okay). Check.

What am I missing?

Make sure you have something similar to the following in your Web.config or App.config.

<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>

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