只有当我在 RELEASE 模式下发布时,EntityFramework.SqlServer.dll 才会添加到已发布的文件夹中

EntityFramework.SqlServer.dll not is getting added to the published folder only when I publish in RELEASE mode(只有当我在 RELEASE 模式下发布时,EntityFramework.SqlServer.dll 才会添加到已发布的文件夹中)
本文介绍了只有当我在 RELEASE 模式下发布时,EntityFramework.SqlServer.dll 才会添加到已发布的文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

仅当我在 RELEASE 模式下发布时才会出现以下错误.原因是已发布文件夹中缺少 EntityFramework.SqlServer.dll.但是,bin 文件夹有 EntityFramework.SqlServer.dll 用于调试和发布模式.

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.

错误:

实体框架提供程序类型'System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer' 在应用程序配置文件中注册对于具有不变名称System.Data.SqlClient"的 ADO.NET 提供程序无法加载.确保程序集限定名称是并且该程序集可用于正在运行的应用程序.

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 模式发布时才会丢失?

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

推荐答案

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

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

经过测试和工作参考:无法加载Entity Framework Provider类型?

这篇关于只有当我在 RELEASE 模式下发布时,EntityFramework.SqlServer.dll 才会添加到已发布的文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)