gpt4 book ai didi

c# - 为什么 add-migration 命令没有创建迁移?不识别包裹

转载 作者:行者123 更新时间:2023-11-30 16:00:08 26 4
gpt4 key购买 nike

安装以下软件包后:

"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0","Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" (-Pre)

运行 add-migration "InitialCreate" 命令时,出现以下错误:

无法执行此命令,因为未安装 Microsoft.EntityFrameworkCore.Design。安装与安装的 Microsoft.EntityFrameworkCore 版本相匹配的包版本,然后重试。 不过,如果您查看下面的 .json 文件,您会发现这些包是匹配的,所以这个错误信息与我矛盾。

这是我的 project.json 文件:

{
"runtimes": {
"win10-x64": {}
},

"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.NETCore.App": "1.1.0"
},

"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},

"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}

最佳答案

您需要更改您的 project.json,如下所示。

注意:需要包含"type": "platform"

{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
}
}
}

您可以在此处阅读有关此问题的更多信息:GitHub

关于c# - 为什么 add-migration 命令没有创建迁移?不识别包裹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40698367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com