我知道 EF6 EntityFramework.SqlServer 存在问题,并且在上下文构造函数中包含 var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
。当我在 DEBUG 模式下发布时它工作正常。
仅当我以 RELEASE 模式发布时才会出现以下错误。原因是发布的文件夹中缺少 EntityFramework.SqlServer.dll
。但是,bin 文件夹中有用于调试和 Release模式的 EntityFramework.SqlServer.dll。
错误:
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.
为什么只有当我使用 RELEASE 模式发布时它才丢失?
最佳答案
不知道为什么;但是将此方法添加到您的上下文将使您的项目复制 dll
private 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;
}
测试和工作 引用:Entity Framework Provider type could not be loaded?
关于c# - 仅当我以 RELEASE 模式发布时,EntityFramework.SqlServer.dll 才不会添加到发布的文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25433298/