当前运行时目标框架与项目不兼容 [英] The current runtime target framework is not compatible with project
问题描述
在将 Entity Framework 7
添加到我的 Asp.Net 5 项目后,我尝试执行初始迁移.我正在关注这个文档.
I am attempting to perform an initial migration after adding Entity Framework 7
to my Asp.Net 5 project. I am following this documentation.
在我的 project.json
中,我指定了:
In my project.json
I have specified:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnxcore50": { }
}
我试图通过命令提示符在项目目录中执行以下命令:
I am attempting to execute the following command in the project directory via a command prompt:
dnx ef migrations add MyFirstMigration
但我收到以下错误:
System.InvalidOperationException:当前运行时目标框架与 ProjectName 不兼容.当前运行时目标框架: 'DNX, Version=v 4.5.1(dnx451) 请确保运行时与 project.json 中指定的框架匹配.
System.InvalidOperationException: The current runtime target framework is not compatible with ProjectName. The current runtime target framework: 'DNX, Version=v 4.5.1(dnx451) Please make sure the runtime matches a framework specified in project.json.
奇怪的是,我的 project.json
肯定是针对 dnxcore50
的.我也签入了 global.json
:
The weird thing is that my project.json
is definitely targeting dnxcore50
. I have also checked in global.json
:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta8",
"architecture": "x86",
"runtime": "coreclr"
}
}
而且我的包依赖都引用了 beta8:
And my package dependencies all reference beta8:
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta8",
"EntityFramework.Core": "7.0.0-beta8",
"EntityFramework.SqlServer": "7.0.0-beta8",
"Hl7.Fhir.DSTU2": "0.90.2",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
"Microsoft.Dnx.Runtime": "1.0.0-beta8",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta8",
"Microsoft.Framework.Logging": "1.0.0-beta8",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta8"
}
推荐答案
您需要将 dnx451
添加到项目支持的框架中,或者切换到 .NET Core 版本.
You need to either add dnx451
to your project's supported frameworks, or switch to a .NET Core version.
"frameworks": {
"dnxcore50": { },
"dnx451": { }
}
或者运行:
dnvm install latest -r coreclr
或
dnvm 使用默认 -r coreclr
这篇关于当前运行时目标框架与项目不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!