EntityFramework.SqlServer.dll not is getting added to the published folder only when I publish in RELEASE mode(只有当我在 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 才会添加到已发布的文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:只有当我在 RELEASE 模式下发布时,EntityFramework.SqlServer.dll 才会添加到已发布的文件夹中


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01