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

查看:16
本文介绍了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, Version = 5.4

我的理解来自

我标记了阅读负责dotnet5.4的部分.另一方面,EntityFramework.Commands 的依赖如下图所示:

没有与新名称 dotnet5.4 对应的.NETPlatform 5.4"部分.

我想这是 EntityFramework.Commandsproject.json的noreferrer">部分:

"netcore50": {斌":{程序集":lib\netcore50\_._"}}

我想必须将行中的 netcore50 更改为 dotnet5.4 以正确支持新的框架名称 dotnet5.4.可以将 "netcore50" 的内容替换为 dnxcore50 的副本(参见 ):

"dotnet5.4": {依赖关系":{"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*","Microsoft.Dnx.Runtime": "1.0.0-*",Microsoft.Extensions.CommandLineUtils.Sources":{"版本": "1.0.0-*",类型":构建"},"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*","System.Console": "4.0.0-*","System.IO.FileSystem": "4.0.1-*"}}

可能应该增加上面引用的 dll 的一些版本号,但是您仍然无法在 "dotnet5.4" 下使用 EntityFramework.Commands 直到将发布新的固定版本.

更新:我向 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天全站免登陆