当前的运行时目标框架与项目不兼容 [英] The current runtime target framework is not compatible with project

查看:296
本文介绍了当前的运行时目标框架与项目不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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中,我指定了:

  "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,版本= 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 use default -r coreclr

这篇关于当前的运行时目标框架与项目不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆