gpt4 book ai didi

c# - 无法加载文件或程序集 'EntityFramework.SqlServer,版本 = 6.0.0.0

转载 作者:太空宇宙 更新时间:2023-11-03 15:32:59 24 4
gpt4 key购买 nike

我在使用 Entity Framework 6.1.3 的 .NET 5.0 Web API 项目中遇到问题。在这个项目中,我需要使用一些使用 Entity Framework 6.0.0 的旧项目的 .Dll 引用。我遇到了异常“无法加载文件或程序集 'EntityFramework.SqlServer,版本 = 6.0.0.0 ......”,但我没有将所有项目中的 Entity Framework 更新为版本 6.1.3。请帮助我!

这是 Project.json:

{
"webroot": "wwwroot",
"version": "1.0.0-*",

"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"EntityFramework": "6.1.3",
"EntityFramework.SqlServer": "7.0.0-beta6",
"EntityFramework.Commands": "7.0.0-beta6",
"structuremap": "3.1.6.186",
"Microsoft.AspNet.Mvc": "6.0.0-beta6",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta6",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"System.ServiceModel.Duplex": "4.0.0-beta-23019",
"System.ServiceModel.NetTcp": "4.0.0-beta-23019",
"System.ServiceModel.Security": "4.0.0-beta-23019"

},

"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
"ef": "EntityFramework.Commands"
},

"frameworks": {
"dnx451": {
"dependencies": {
"CuttingEdge.Conditions": "1.0.0-*",
"Quartz": "1.0.0-*",
"Project.Application": "1.0.0-*",
"Project.Finance": "1.0.0-*",
"Project.Infrastructure": "1.0.0-*",
"Project.QuartzScheduler": "1.0.0-*",
"Project.ServiceDesks": "1.0.0-*",
"Project.Utilities": "1.0.0-*",
"Project.WCFMock": "1.0.0-*"
},
"frameworkAssemblies": {
"System.ServiceModel": "4.0.0.0"
}
}
},

"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}

我已将旧项目中的 Entity Framework 更新为版本 6.1.3 并在 App.config 中进行设置:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

但是还是会出现上面的异常。请帮助我!

这是完整的错误:

Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

最佳答案

您的问题是您正在加载 EF6 和 EF7(您的 project.json 中有这两个版本)。您应该将 EntityFramework.SqlServer 降级到版本 6,或者将您的 EntityFramework 升级到版本 7。

换句话说,要么使用 EF6 要么使用 EF7,但不要混合使用不同版本的程序集。

"EntityFramework": "6.1.3",
"EntityFramework.SqlServer": "7.0.0-beta6",
"EntityFramework.Commands": "7.0.0-beta6",

关于c# - 无法加载文件或程序集 'EntityFramework.SqlServer,版本 = 6.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33100445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com