當前運行時目標框架與項目不兼容

asp.net-core entity-framework-core

我在向我的Asp.Net 5項目添加Entity Framework 7後嘗試執行初始遷移。我正在關注此文檔

在我的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"
  }

一般承認的答案

您需要將dnx451添加到項目支持的框架中,或者切換到.NET Core版本。

  "frameworks": {
    "dnxcore50": { },
    "dnx451": { }
  }

或運行:

dnvm install latest -r coreclr

要么

dnvm use default -r coreclr



許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因