参考:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/aa542153-b2a5-4b14-98a3-572f7b028c61/updated-to-ef6-and-now-my-unittests-dont-work-systemdatasqlclient-could-not-be-loaded?forum=adodotnetentityframework
http://thecurlybrace.blogspot.com/2013/11/entity-framework-5-to-601-upgrade.html
http://robsneuron.blogspot.com/2013/11/entity-framework-upgrade-to-6.html
原因:项目代码中没有显示引用 System.Data.Entity.SqlServer.SqlProviderServices 的成员,编译器在编译的时候会优化掉,VS中引用了System.Data.Entity.SqlServer,但编译的时候会把这个引用删掉。
public class MyDbContext : DbContext
{ static MyDbContext ()
{
var _ = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
var __ = typeof(System.Data.Entity.SqlServerCompact.SqlCeProviderServices);
} ..... }