EntityFramework.SqlServer.dll没有被添加到已发布的文件夹,只有当我发布在RELEASE模式 [英] EntityFramework.SqlServer.dll not is getting added to the published folder only when I publish in RELEASE mode

查看:617
本文介绍了EntityFramework.SqlServer.dll没有被添加到已发布的文件夹,只有当我发布在RELEASE模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道EF6 EntityFramework.SqlServer有一个问题,并在上​​下文构造函数中包含 var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices); 。当我以DEBUG模式发布时,它的工作正常。



仅当我在RELEASE模式下发布时,才能获得以下错误。原因是发布的文件夹中缺少 EntityFramework.SqlServer.dll 。但是,bin文件夹具有用于调试和发布模式的EntityFramework.SqlServer.dll。



错误:


实体框架提供程序类型
'System.Data.Entity.SqlServer.SqlProviderServices,
EntityFramework.SqlServer'注册在应用程序配置文件
为ADO.NET提供程序使用不变名称'System.Data.SqlClient'
无法加载。确保使用的组合标识名称为
,并且程序集可用于正在运行的应用程序。


为什么只有当我使用RELEASE模式发布时才会丢失?

解决方案

不知道为什么;但是将此方法添加到您的上下文将使您的项目复制dll

  private void FixEfProviderServicesProblem()
{
//实体框架提供程序类型'System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer'
//对于'System.Data.SqlClient'ADO.NET提供程序无法加载。
//确保提供程序程序集可用于正在运行的应用程序。
//有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=260882。
var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}

测试和工作
参考:无法加载实体框架提供者类型


I know there is a problem with EF6 EntityFramework.SqlServer and included var type = typeof(System.Data.Entity.SqlServer.SqlProviderServices); in context constructor. It works fine when i do publish in DEBUG mode.

Getting the below error only when I publish in RELEASE mode. The reason is EntityFramework.SqlServer.dll missing in the published folder. But, bin folder has EntityFramework.SqlServer.dll for both debug and release mode.

Error:

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.

Why is it missing only when I publish using RELEASE mode?

解决方案

Don't know why; but adding this method to your context will make your project copy the 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;
        }

Tested and working Reference: Entity Framework Provider type could not be loaded?

这篇关于EntityFramework.SqlServer.dll没有被添加到已发布的文件夹,只有当我发布在RELEASE模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆