2

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?

2
  • Did you install EF6 via NuGet on the WCF project? Commented Jun 12, 2014 at 14:13
  • Multiproject solution. Running it in the PM console added it to both projects, modified both .config files to sync up to the same version. Moo pointed me in the right direction. Commented Jun 12, 2014 at 14:26

1 Answer 1

6

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>
Sign up to request clarification or add additional context in comments.

4 Comments

That did it. It was already in the app config but not the web config. It doesn't error on that line anymore but is now blathering on about no insert function existing or some nonsense. You get the answer and the vote! Thanks
Question: why does the MVC project need to have the data information in web.config even though the WCF service is the one accessing the database?
That's because .net uses the config file of the calling application by default. Which in most cases is the main web/windows application.
Thanks. I guess I'm thinking a bit too extreme in the "modular coding" paradigm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.