【发布时间】:2016-05-02 12:47:24
【问题描述】:
这是我第一次使用 VS2015 试验 EF Core、ASP Net Core 和可移植类库。公平地说,我感到很沮丧。
我想创建一个可以安装 EntityFramework.Core 的库。这个库需要在 WPF 应用程序和 ASP NET Core Web 应用程序中使用——暂时忽略任何好的分层应用程序概念。我的想法是创建一个可移植类库。
使用我面向 .NET 4.6 和 ASP Net Core 的项目模板...
我得到一个项目,其中包含一个类和一个 project.json 文件,如下所示:
{
"supports": {
"net46.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0"
},
"frameworks": {
"dotnet": {
"imports": "portable-net452"
}
}
}
现在当我从 nuget 安装 EntityFramework.Core 包时...
...我得到以下输出:
Restoring packages for 'Acme.PCLEFClassLib'.
Restoring packages for K:\TFS\TestApps\Projects\DotNetCore\Acme.PCL1\Acme.PCL1\project.json...
Detected package downgrade: System.Reflection from 4.1.0-beta-23225 to 4.0.10
Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 1.0.0-rc1-final) -> System.Reflection (>= 4.1.0-beta-23225)
Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Reflection (>= 4.0.10)
Detected package downgrade: System.Reflection from 4.1.0-beta-23225 to 4.0.10
Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> Microsoft.Extensions.Logging.Abstractions (>= 1.0.0-rc1-final) -> System.Reflection (>= 4.1.0-beta-23225)
Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Reflection (>= 4.0.10)
Version conflict detected for System.Collections.
Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Collections (>= 4.0.11-beta-23516)
Acme.PCLEFClassLib (>= 1.0.0) -> Microsoft.NETCore.Portable.Compatibility (>= 1.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-x86 (>= 1.0.0) -> System.Collections (= 4.0.10).
EntityFramework.Core 7.0.0-rc1-final is not compatible with .NETPlatform,Version=v5.0.
Some packages are not compatible with .NETPlatform,Version=v5.0.
Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0.
Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0.
Some packages are not compatible with DNXCore,Version=v5.0.
Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0 (win7-x86).
Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0 (win7-x86).
Some packages are not compatible with DNXCore,Version=v5.0 (win7-x86).
Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0 (win7-x64).
Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0 (win7-x64).
Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).
Package restore failed for 'Acme.PCLEFClassLib'.
Package restore failed. Rolling back package changes for 'Acme.PCLEFClassLib'.
========== Finished ==========
实际上是否可以在可移植类库中安装 EF Core?如果是这样,我需要如何处理该项目?
我只是觉得我在网上兜圈子寻找解决方案。
更新 1
尝试在我的 PCL 中安装 EntityFramework.MicrosoftSqlServer。
鉴于在创建标准 ASP Net Core 项目时安装了 EntityFramework.MicrosoftSqlServer - 该项目使用 dnxcore50 框架。如果我在 PCL 中做类似的事情,为什么会抱怨:
EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final is not compatible with .NETPlatform,Version=v5.0.
如果是这样,那么它如何安装到 ASP NET Core 项目中。
更新 2
我创建了一个针对 .NET 4.5.1 的新 PCL。然后我通过 Nuget 将 EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final 安装到其中,并且安装没有问题。虽然我现在不能重复这一点。我刚刚使用针对 ASP NET Core 和 .NET 4.5.1 的 PCL 库项目创建了一个单独的解决方案。现在输出以下内容:
Attempting to gather dependency information for package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' with respect to project 'AnotherPCLEFFUP', targeting '.NETPortable,Version=v4.5,Profile=Profile75'
Attempting to resolve dependencies for package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' with DependencyBehavior 'Lowest'
Resolving actions to install package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final'
Resolved actions to install package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final'
Install failed. Rolling back...
Package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' does not exist in project 'AnotherPCLEFFUP'
Package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' does not exist in folder 'K:\TFS\TestApps\Projects\DotNetCore\AnotherPCLEFFUP\packages'
Invalid portable frameworks.
安装 EntityFramework.Core.7.0.0-rc1-final 也会发生同样的情况。
公平地说,这完全令人沮丧。也许我今天在叫错树,或者只是在狂吠。
【问题讨论】:
-
在atm遇到同样的问题
-
嗨,这显然是 GitHub 上的一个未解决问题:github.com/aspnet/EntityFramework/issues/5176(破坏依赖关系)
-
我只能说这是团队的不负责任。有一个 RC 甚至没有正确安装,甚至有很多问题,而且实际上已经 5 个月没有更新,这是完全不能接受的!负责任的事情是至少有一个实用路线图,同时要做什么,否则,他们应该从 Nuget 拉出这些 RC。上周我在常规 .NET 4.6 上安装了 EFCore,并且在安装(以及在荒谬的变通方法之后)然后运行它时遇到了很多重大问题,只是发现这些错误 已在 myget rc2 版本中修复。
标签: entity-framework portable-class-library entity-framework-core