A tag team championship battle between Entity Framework, NuGet vs TeamCity, SQL Provider

Recently we have upgraded our entity framework through NuGet and had all our unit test cases passing locally. Everything started to fail on TeamCity build server and there was not much stack trace displayed in the build log. After looking into detailed unit test logs, I finally found out that we were having issue with Entity Framework cannot find SQL Provider.

After couple of hours of looking up on the web, I finally stumbled up on this awesome blog by Rob Lang where he describes each and every scenario to fix the problem. In my case adding the below block of code to ClassInitializer helped me out to fix the problem.

public void FixEfProviderServicesProblem()
{
//The Entity Framework provider type ‘System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer’
//for the ‘System.Data.SqlClient’ ADO.NET provider could not be loaded.
//Make sure the provider assembly is available to the running application.
//See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}

Hope this helps someone in future.

Regards,
Adi

Advertisements