![](/img/trans.png)
[英]Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
[英]Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0
我在使用Entity Framework 6.1.3的.NET 5.0 Web API項目中遇到問題。 在這個項目中,我需要使用一些使用Entity Framework 6.0.0的舊項目的.Dll引用。 沒有我沒有將所有項目中的實體框架更新為6.1.3版的情況下,出現了異常“無法加載文件或程序集'EntityFramework.SqlServer,Version = 6.0.0.0 ......”。 請幫我!
這是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"
]
}
我已將舊項目中的實體框架更新為版本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",
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.