ASPNET5类库抛出当前运行时目标框架与&#39; <projectname>&#39;

时间:2016-01-18 13:02:26

标签: asp.net entity-framework dnx .net-core dnvm

我想在一个单独的类库项目(名称为AbsenceRequests.Data.EF)中进行EntityFramework工作,以便可以单独维护它。

我遇到了project.json系统的一些问题,当前看起来像这样:

{
  "version": "1.0.0-*",
  "description": "AbsenceRequests.Data.EF Class Library",
  "authors": [ "authorName" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {    
    "netcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  },
  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"
  }
}

当我在命令行上运行dnx ef时,我收到以下错误:

C:\...\AbsenceRequests\AbsenceRequests.Data.EF>dnx ef
System.InvalidOperationException: The current runtime target framework is not compatible with 'AbsenceRequests.Data.EF'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
 Version:      1.0.0-rc1-16202
 Type:         Clr
 Architecture: x86
 OS Name:      Windows
 OS Version:   6.1
 Runtime Id:   win7-x86

Please make sure the runtime matches a framework specified in project.json
   bij Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicatio
nName)
   bij Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, Strin
g applicationName, String[] args)
   bij Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetrede
n ---
   bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bij Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly
, String[] args, IServiceProvider serviceProvider)
   bij Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment
 env, String appBase, FrameworkName targetFramework)
   bij Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, Bootst
rapperContext bootstrapperContext)
   bij Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, Bootstrappe
rContext bootstrapperContext)

当我使用常规Web项目(甚至从头开始)时,这很有效。但是对于类库项目,这会失败。任何人的想法?我做错了什么?

由于 伊夫

1 个答案:

答案 0 :(得分:4)

我自己遇到了这个问题,我通过在project.json中添加以下内容来解决。

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

当我最初创建类库项目并将其更改为dnx451时,将其设置为net451。确保它知道该项目将使用哪些框架版本。