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 才会添加到已发布的文件夹中


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01