【发布时间】:2017-05-26 07:26:22
【问题描述】:
我对 .NET Core 比较陌生,我有一个 .NET Core WebAPI 项目 MyWebApp,
另外,我有 .Net Core 类库项目 MyLib 使用 EntityFrameworkCore
当我尝试使用 Add-Migration 时,出现错误
指定的deps.json [...\MyWebApp\bin\Debug\netcoreapp1.1\MyWebApp.deps.json] 不存在
检查文件夹,我注意到我在 [...\MyWebApp\bin\Debug\netcoreapp1.1\win10-x64\MyWebApp.deps.json] 中有一个文件
但我真的不知道我应该做些什么来解决这个问题。
myWebApi 项目.json:
{
"dependencies": {
"ShopManager": "1.0.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": "1.1.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"runtimes": {
"win10-x64": ""
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
【问题讨论】:
-
感谢您的评价
-
从
project.json中删除runtimes部分。只要您不使用其他运行时 - 它就没有用。另外,Microsoft.EntityFrameworkCore.*包在哪里,为什么它们没有在依赖项中列出? -
EFCore.* 在类库中。当我删除 RT 部分时,我收到一个错误,要求它用于 .NetCore.App 依赖项
-
移除
runtimes并将依赖关系重写为"Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" }。这是关于 deployment model 的,我在“错误”的 depl 中遇到了一些问题。类型。 -
@Dmitry 谢谢,它有效,请将其作为答案,如果你能详细说明依赖类型,因为从微软的教程中,我仍然不明白有什么区别和为什么需要它?
标签: entity-framework .net-core entity-framework-core entity-framework-migrations project.json