ASP.Net 5类库包中的EntityFramework命令? [英] EntityFramework Commands in ASP.Net 5 Class Library Package?

查看:193
本文介绍了ASP.Net 5类库包中的EntityFramework命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发我的第一个ASP.Net Web应用程序,在我的解决方案中,我有两个项目。 Web应用程序类库(软件包)。在构建此应用程序的ASP.Net 4.5版本时,我将 Entity Framework 6 实体放入类库中,所以我在中进行了此操作ASP.Net 5 版本。问题是当我在类库中安装 EntityFramework.Commands 时出现错误:


Project DBEntities中的EntityFramework.Command 7.0.0-rc1-final依赖项不支持框架.NetPlatform,版本= 5.4


我对



我已标记为负责 dotnet5.4 。另一方面, EntityFramework.Commands 的依赖关系如下图所示:





其中没有对应于新名称 dotnet5.4



我认为这是 project.json EntityFramework的一部分 。命令

  netcore50:{ 
bin:{
assembly: lib\\netcore50\\ _._
}
}

我想必须将 netcore50 更改为 dotnet5 .4 支持新框架名称 dot net5.4 正确。应该将 netcore50 的内容替换为 dnxcore50 的副本(请参阅):

  dotnet5.4:{
dependencies:{
Microsoft.AspNet.Hosting.Abstractions : 1.0.0- *,
Microsoft.Dnx.Runtime: 1.0.0- *,
Microsoft.Extensions.CommandLineUtils.Sources:{
version: 1.0.0- *,
type: build
},
Microsoft.Extensions.PlatformAbstractions: 1.0.0- *,
System.Console: 4.0.0- *,
System.IO.FileSystem: 4.0.1- *
}
}

可能应该增加上面引用的dll的某些版本号,但是您仍然无法使用 dotnet5.4 下的$ c> EntityFramework.Commands 直到新的固定v会发布。



已更新::我摆了问题给EntityFramework开发人员团队。得到后,我会附上Microsoft对这个问题的回复。


I am trying to develop my first ASP.Net web application and in my solution I have two projects. A Web Application and Class Library (Package). When I build the ASP.Net 4.5 version of this application I put my Entity Framework 6 entities into a class library, so I am doing that in the ASP.Net 5 version. The problem is when I install EntityFramework.Commands to the class library I get the error:

The dependency EntityFramework.Command 7.0.0-rc1-final in Project DBEntities does not support framework .NetPlatform, Version = 5.4

My understanding from this SO question is that dotnet5.4 is the new .Net 5 which is supposed to be supported by EF7.

Here is my project.json file:

{
  "version": "1.0.0-*",
  "description": "FFInfo.DAL Class Library",
  "authors": [ "Mathew" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
    "frameworks": {
        "dotnet5.4": {
            "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"
    }
}

Did I install the wrong package, is EF7 changed so much that I am building out the class wrong, or am I missing something in my json file?

EDIT: New project.json file based off suggestions

{
    "version": "1.0.0-*",
    "description": "FFInfo.DAL Class Library",
    "authors": [ "Mathew" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",
    "frameworks": {
        "dotnet5.4": {
            "dependencies": {
                "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
                "Microsoft.Dnx.Runtime": "1.0.0-*",
                "Microsoft.Extensions.CommandLineUtils.Sources": {
                    "version": "1.0.0-*",
                    "type": "build"
                },
                "Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
                "System.Console": "4.0.0-*",
                "System.IO.FileSystem": "4.0.1-*"
            }
        },
        "netcore50": {
            "bin": {
                "assembly": "lib\\netcore50\\_._"
            }
        },
        "dependencies": {
            "EntityFramework.Commands": "7.0.0-rc1-final",
            "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"
        }
    }
}

解决方案

I suppose that the reason of your problem have pure technical nature. The announcement declares renaming of dnx451 to net451 and dnxcore50 to dotnet5.4, but one recommend to use such renaming only for class libraries (which you publich on NuGet for example to share with other). If I understand you correctly, that you develop application which uses class libraries and thus you should use dnxcore50 instead of dotnet5.4. Thus you need just rename the string "dotnet5.4" to the string "dnxcore50" in the fileproject.json` to fix the problem.

Independent from the above recommendation I want to add my understanding of your problem, why you get the error about EntityFramework.Command 7.0.0-rc1-final.

I understand the renaming of frameworks as the step in direction to future changes which plan Microsoft. On the other side all names of frameworks will be interpreted just as different names. I suggest you to compare the information about the dependencies displayed on the page https://www.nuget.org/packages/EntityFramework.Commands/7.0.0-rc1-final from the corresponding information from https://www.nuget.org/packages/EntityFramework.MicrosoftSqlServer/7.0.0-rc1-final. The dependencies of EntityFramework.MicrosoftSqlServer (which have no problems with the usage of dotnet5.4) looks like on the picture

I marked read the part responsible for dotnet5.4. On the other side the dependencies of EntityFramework.Commands looks like on the picture below:

where there are no ".NETPlatform 5.4" section which corresponds the new name dotnet5.4.

I suppose that it's a bug in the part of project.json of EntityFramework.Commands:

"netcore50": {
  "bin": {
    "assembly": "lib\\netcore50\\_._"
  }
}

I suppose that one have to change netcore50 to dotnet5.4 in the lines to support new framework name dotnet5.4 correctly. One chould replace the content of "netcore50" to the copy from dnxcore50 (see the lines):

"dotnet5.4": {
  "dependencies": {
    "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
    "Microsoft.Dnx.Runtime": "1.0.0-*",
    "Microsoft.Extensions.CommandLineUtils.Sources": {
      "version": "1.0.0-*",
      "type": "build"
    },
    "Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
    "System.Console": "4.0.0-*",
    "System.IO.FileSystem": "4.0.1-*"
  }
}

Probably one should event increase some version numbers of the dlls referenced above, but you still will be not able to use EntityFramework.Commands under "dotnet5.4" till the new fixed version will be published.

UPDATED: I posed the issue to the EntityFramework developer team. I'll include the response from Microsoft on the issue after I'll get it.

这篇关于ASP.Net 5类库包中的EntityFramework命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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