19 November 2013

Entity Framework 5 to 6.0.1 Upgrade SqlProviderServices Exception

Today, I decided to update my Entity Framework (EF) 5.0 NuGet packages to EF 6.0.1. No problem updating; NuGet did its duty, as usual. However, a great number of the Model project tests failed, and executing the application threw an exception, as expected:

The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider 
with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. 
See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

As usual, the link provided minimal assistance. With a little prodding, I found a workaround for the issue.

The goal of this post is to make as few modifications to the code base as possible, to make the EF5 to EF6 upgrade. Sure, there are some differences between EF5 and EF6 implementation, but we're ignoring that for now. EF6 does not require data provider configurations in the App.config file. The new ProviderService types, embedded in the System.Data.Entity.(ProviderName) namespace does this for us. But, these are the objects giving us trouble. First things first...