参考:

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);
        }

.....

}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-03-09
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2021-12-01
  • 2021-06-01
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
相关资源
相似解决方案