Buildserver can not find Entity Framework Sql Provider

梦想与她 提交于 2019-12-04 18:43:42

问题


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?


回答1:


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...



来源:https://stackoverflow.com/questions/22478327/buildserver-can-not-find-entity-framework-sql-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!