Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buildserver can not find Entity Framework Sql Provider

We are in the process of switching from Entity Framework 4 to Entity Framework 6. The package manager did its job, and the solution ran it’s tests without a hitch.

However on the build server we get the following error message running the tests: Initialization method xxx.SetUp threw exception. System.InvalidOperationException:

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.

If we open the solution locally on the build server, with a Visual Studio installed there, the test run without error again.

We use Cruise Control .Net in combination with SVN as tooling for our continuous integration. Ms Build is used to build the solution and the tests are run with Ms Test.

Has anybody experienced similar problems or has any thoughts on a solution?

like image 729
k.c. Avatar asked Mar 18 '14 11:03

k.c.


1 Answers

This really sucks MS. But fortunately some better programmer than I had the same problem and made this excellent post: http://robsneuron.blogspot.nl/2013/11/entity-framework-upgrade-to-6.html

Adding this line to our DbContext constructor fixes the problem:

var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

The variable is never used, is not needed when using VS to build, it is only there to make sure Ms Build does its job...

like image 113
k.c. Avatar answered Oct 20 '22 14:10

k.c.