asp.net-core – 当前的运行时目标框架与项目不兼容

前端之家收集整理的这篇文章主要介绍了asp.net-core – 当前的运行时目标框架与项目不兼容前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在向我的Asp.Net 5项目添加Entity Framework 7后尝试执行初始迁移.我关注这个 documentation.

在我的project.json中我指定了:

"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel","ef": "EntityFramework.Commands"
  },"frameworks": {
    "dnxcore50": { }
  }

我试图通过命令提示符在项目目录中执行以下命令:

dnx ef migrations add MyFirstMigration

但是我收到以下错误

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:

{
  "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安装最新的-r coreclr

要么

dnvm使用default -r coreclr

原文链接:https://www.f2er.com/aspnet/251826.html

猜你在找的asp.Net相关文章