我在将 Entity Framework 7
添加到我的 Asp.Net 5 项目后,正试图执行初始迁移。 我正在遵循这个 文档。
在我的project.json
文件中,我已经指定:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnxcore50": { }
}
我尝试通过命令提示符在项目目录中执行以下命令:
dnx ef migrations add MyFirstMigration
但我收到了以下错误:
System.InvalidOperationException:当前运行时目标框架与 ProjectName 不兼容。当前运行时目标框架:'DNX,Version=v 4.5.1(dnx451)'。请确保运行时与 project.json 中指定的框架匹配。
奇怪的是,我的 project.json
明确地针对 dnxcore50
。我还在 global.json
中进行了检查:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta8",
"architecture": "x86",
"runtime": "coreclr"
}
}
我的软件包依赖关系都引用了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"
}
project.json
文件中指定了dnxcore50
框架。我运行了dnvm install latest -r coreclr
,现在它可以工作了。但是为什么呢?该命令说明我已经安装了最新的core CLR运行时。 - Blake Mumford