gpt4 book ai didi

entity-framework - 未找到与命令 "dotnet-ef"匹配的可执行文件

转载 作者:行者123 更新时间:2023-12-03 05:13:47 26 4
gpt4 key购买 nike

我正在通过将 ASP.Net Core RC2 与 Microsoft.EntityFramework.Core 和 SQLite 结合使用来制作项目示例。

我已经按照本教程进行操作: https://damienbod.com/2015/08/30/asp-net-5-with-sqlite-and-entity-framework-7/

但是,当我运行此命令时:

dotnet ef migrations add FirstMigration

我收到此错误:

No executable found matching command "dotnet-ef"

这是我的 project.json 配置:

{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final"
},

"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},

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

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

"runtimeOptions": {
"gcServer": true
},

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

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

最佳答案

Entity Framework Core 1.0

您应该只需要更新 project.json 文件的 tools 部分即可包含以下内容:

"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}

这应该使 dotnet ef 命令可用。

重要

我还应该注意到,dotnet ef 命令仅在从包含 project.json 文件的同一目录运行它们时才可用。

Entity Framework Core 1.1
如果您在升级到 Entity Framework Core 1.1 后再次遇到此问题,请务必将 Microsoft.EntityFrameworkCore.Tools 依赖项替换为 Microsoft.EntityFrameworkCore.Tools.DotNet 版本 1.1.0-preview4。也无需保留 imports 部分。有关详细信息,请参阅 Entity Framework Core 1.1 release announcement blog post 下的“升级到 1.1”标题。 .

关于entity-framework - 未找到与命令 "dotnet-ef"匹配的可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37276882/

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