And*_*dez 5 entity-framework portable-class-library entity-framework-core
这是我第一次使用VS2015试用EF Core,ASP Net Core和Portable Class Libraries.公平地说我感到沮丧.
我想创建一个库,我可以在其中安装EntityFramework.Core.这个库需要在WPF应用程序和ASP .NET核心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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在当我从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 ==========
Run Code Online (Sandbox Code Playgroud)
实际上是否可以在便携式类库中安装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.
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,那么它如何安装到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 Library项目.现在输出以下内容:
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.
Run Code Online (Sandbox Code Playgroud)
安装EntityFramework.Core.7.0.0-rc1-final也是如此.
可以说,这非常令人沮丧.也许我正在咆哮错误的树或今天只是疯狂.
我不知道这将如何满足您的可移植类需求,但对于常规 .NET(4.6 或等),我发现了以下内容。(见下面的吐槽)
所以我不知道这是否是“犹太洁食”,但这个来源现在有效:
添加nuget包源(选项-包源-添加(加号)
- 名称:'aspnetrelease'(或任何你想要的)
- 来源:' https://www.myget.org/F/aspnetrelease/api/v3/index.json '
如果您要安装 SqlServer,只需安装以下命令:
Microsoft.EntityFrameworkCore.SqlServer
或者选择另一个顶级依赖项,它将获取所有其他所需的依赖项。
*[begin-rant] 这只是通过在 EF github 讨论中搜索得到的。他们没有一个实际的描述来解释现在该做什么,这是完全不可原谅的。他们应该撤回“RC”1 版本,其中包含所有错误,其设计与他们现在正在开发的版本完全不同,并且已经 5 个多月没有更新了(!这是与“pre -release' 标记已选中!),完全来自 nuget。
让我补充一下:我喜欢这些人所做的一切,我喜欢新的东西,很多非常好的东西。但我们不应该让一个据称仍然标记为“RC”的版本悬而未决,因为它充满了已经在彻底重新设计的 rc2 版本中修复的错误,而他们还没有公开这些错误。[/结束咆哮]*
| 归档时间: |
|
| 查看次数: |
2654 次 |
| 最近记录: |