我正在尝试开发我的第一个ASP.Net Web应用程序,在我的解决方案中,我有两个项目。一个Web Application
和Class Library (Package)
。在构建此应用程序的ASP.Net 4.5版本时,我将Entity Framework 6
实体放入类库中,因此我在ASP.Net 5
版本中进行了此操作。问题是,当我将EntityFramework.Commands
安装到类库时,出现错误:
The dependency EntityFramework.Command 7.0.0-rc1-final in Project DBEntities does not support framework .NetPlatform, Version = 5.4
我对this SO question的理解是
dotnet5.4
是新的.Net 5,应该由EF7支持。这是我的
project.json
文件:{
"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"
}
}
我安装了错误的软件包吗?EF7发生了太大变化以至于我建立了错误的类吗?还是我的json文件中丢失了某些内容?
编辑:
基于建议的新project.json文件
{
"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"
}
}
}
最佳答案
我想您出现问题的原因纯粹是技术性的。 The announcement声明将dnx451重命名为net451,将dnxcore50重命名为dotnet5.4,但建议仅将此类重命名用于类库(例如,您在NuGet上公开了此名称,以便与其他库共享)。如果我理解正确,那您将开发使用类库的应用程序,因此应使用dnxcore50
而不是dotnet5.4
。因此,您只需要将字符串“dotnet5.4”重命名为字符串"dnxcore50" in the file
project.json`即可解决问题。
独立于上述建议,我想补充一下您的问题,为什么会出现关于EntityFramework.Command 7.0.0-rc1-final的错误。
我了解框架的重命名是迈向计划Microsoft的 future 更改的一步。另一方面,框架的所有名称将被解释为不同的名称。我建议您将https://www.nuget.org/packages/EntityFramework.Commands/7.0.0-rc1-final上的相关信息与https://www.nuget.org/packages/EntityFramework.MicrosoftSqlServer/7.0.0-rc1-final上的相应信息进行比较。 EntityFramework.MicrosoftSqlServer
的依赖项(与dotnet5.4
的使用没有关系)看起来像在图片上
我标记为负责dotnet5.4
的部分。另一方面,EntityFramework.Commands
的依赖关系如下图所示:
没有对应新名称dotnet5.4
的“.NETPlatform 5.4”部分。
我想这是,是project.json
的EntityFramework.Commands
的the part中的错误:
"netcore50": {
"bin": {
"assembly": "lib\\netcore50\\_._"
}
}
我想必须将各行中的
netcore50
更改为dotnet5.4
才能正确支持新的框架名称dotnet5.4
。应该将"netcore50"
的内容替换为dnxcore50
的副本(请参阅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-*"
}
}
事件可能会增加上面引用的dll的某些版本号,但在新的固定版本发布之前,您仍然无法使用
EntityFramework.Commands
下的"dotnet5.4"
。更新:我向EntityFramework开发人员团队介绍了the issue。得到后,我将包括Microsoft对这个问题的答复。
关于asp.net-core - ASP.Net 5类库包中的EntityFramework命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34370874/