Entity Framework can not find 'System.Data.SqlClient'

1

After installing and uninstalling EF 6.1.3 in several projects of my solution, when I wanted to use it I had the following problem:

  

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 link for more information.

To EF I have it wrapped ( wrappeado ), to avoid referencing the assemblies of EF in other projects, with the pattern of Unit of Work.

I was researching SOen on the following questions and they could not solve my problem:

I chose not to apply the following solutions because, in my opinion, its implementation generates doubts and they are walk-arounds :

  • Load the assembly to the Java; making a call the instance of the provider.
  • Referencing the EF in the initial project, together with its supplier.
  • Make a copy after compiling the file EntityFramework.SqlServer.dll
asked by drielnox 27.01.2016 в 14:25
source

1 answer

1

After touching a lot I solved it by deleting the entries related to EF in the app.config of each project of the solution, except for where I implement Code First .

Apparently, when EF wants to load the SqlServer provider assembly, it will look for such an assembly to the project where it has the provider definition and where the initial call is made > (the first call of the call stack). In my case, it was the project where I had the Windows forms, in the presentation layer.

Likewise, before realizing this, make the following list of verifications to solve possible intermediate problems.

  • I uninstalled EF from the entire solution, either by NuGet or the package console.
  • I deleted the orphan references of all the projects.
  • I deleted the orphaned assemblies of all the projects.
  • After that, I proceeded with the reinstallation of EF:

  • I installed EF via the package console to the desired project: Install-Package EntityFramework
  • Verify that the EntityFramework.SqlServer reference makes a local copy.
  • answered by 27.01.2016 / 14:25
    source