这是我第一次尝试使用EF、ASP.NETCore和VS2015的便携式类库。平心而论,我现在很沮丧。
我想要创建一个可以安装EntityFramework.Core的库。这个库需要在WPF应用程序和ASP.NET核心Web应用程序中使用--暂时忽略任何良好的分层应用程序概念。我的想法是创建一个便携式类库。
使用我针对.NET 4.6和ASP.NET核心的项目模板.

我得到一个带有类和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软件包时..。

...I获得以下输出:
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吗?如果是这样的话,我该如何处理这个项目呢?
我只是觉得我正在绕圈寻找解决方案的在线。
更新1
尝试在我的个人电脑里安装EntityFramework.MicrosoftSqlServer。
鉴于EntityFramework.MicrosoftSqlServer是在创建标准ASP.NETCore项目时安装的,该项目使用dnxcore50框架。如果我在PCL中做了类似的事情,为什么会抱怨:
EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final is not compatible with .NETPlatform,Version=v5.0.如果是这样的话,那么它怎么会安装到ASP.NET核心项目中呢?
更新2
我创建了一个针对.NET 4.5.1的新的PCL。然后我通过Nuget将EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final安装到其中,它没有问题。虽然我现在不能重复。我刚刚创建了一个针对ASP.NETCore和.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-决赛也会发生同样的情况。
公平地说,这是完全令人沮丧的。也许我今天的吠声是错的,或者只是狂吠。
发布于 2016-05-03 23:00:29
我不知道如何满足您的便携式类需求,但对于常规.NET (4.6或其他),我发现了以下内容。(见下文的咆哮)
所以我不知道这是不是“犹太”,但这个消息来源现在是可行的:
添加nuget包源(选项-包源-添加(加号)
如果您正在为SqlServer安装,只需安装以下内容:
Microsoft.EntityFrameworkCore.SqlServer
或者选择另一个顶级依赖项,它将获取所有需要的其他依赖项。
*开始--那只是在EF github的讨论上四处奔走。他们没有一个实际的描述来解释现在该做什么,这是完全不可原谅的。他们应该拉"RC"1版本,与其所有的错误,和它的根本不同的设计与现在的工作,并没有更新超过5个月(!这是与‘预释放’标记检查!),完全来自nuget。
让我补充一句:我喜欢这些人所做的一切,我喜欢新的部分,很多非常好的东西。但是我们不应该因为一个所谓的"RC“版本而被挂上半年的时间,当它充满了已经被彻底重新设计的rc2版本中已经修复的But时,这个版本还没有被公之于众。/结束-咆哮*
发布于 2016-06-22 07:43:45
您是否尝试过将框架导入更改为:
"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net451+win8"
}
}发布于 2016-06-25 12:55:17
我创建了一个项目类库核心4.6,并在project.json中使用这段代码
{
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
}
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
}
}https://stackoverflow.com/questions/36982847
复制相似问题