0
votes

I have the following MVC project structure:

BLL

DAL

CommonClasses

Web

i'm using Entity Framework 6.0.2. The web project has a reference to the BLL and CommonClasses project. BLL has a reference to DAL and CommonClasses. Both BLL and DAL also have references to EF 6.0.2, added via Nuget. Anytime my code tries to do anything with Entity Framework I get the error below:

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.

I'm a bit lost on what's happening. I have checked and there is a reference to EntityFramework.SqlServer in the DAL and BLL projects. All projects also have a reference to System.Data.

The app.config file in both the DAL and BLL proejcts has the below line:

  <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

2

2 Answers

3
votes

Ensure that EntityFramework.SqlServer.dll is in the application directory for Web1 (i.e. in the bin folder). It doesn't always get copied if the top-level executable/site doesn't have a direct dependency on this file.

1
votes

Please see my SO answer here, which references a blog that was very helpful. I had to do a couple of steps to get that DLL copied and loaded.

Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'