0

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>
asked Apr 16, 2014 at 15:55
2

2 Answers 2

2

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.

answered Apr 16, 2014 at 16:01
2
  • Is there anyway to add in via Visual Studio to it's always there for anyone else who grabs the project? I just manually copied it into the bin and it worked, but how to do it through VS? If I try to add a reference to it in the project, i don't see EntityFramework.SqlServer in the search results. Commented Apr 16, 2014 at 16:06
  • The hackiest (TM) way to do it is doing something like this and add a reference into the project using EntityFramework, then it'll get included as a dependency in any downstream projects: internal static readonly Type SqlProviderServicesType = typeof(System.Data.Entity.SqlServer.SqlProviderServices); Commented Apr 16, 2014 at 16:11
1

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'

answered Apr 27, 2014 at 23:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.