我有一个 Asp Net Core 项目,与 EF Core 3.0 相关,并在 GitHub 上建立了一个仓库。我添加了以下工作流程,以便在更新 develop
分支时每次运行。
name: Develop Build
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.102-servicing-014397
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
run: dotnet test --configuration Release
- name: Update database
run: dotnet ef database update --c DataContext --p MyProj --s MyProjFactory
最后一行返回了一个错误:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
##[error]Process completed with exit code 1.
如何使用此工作流将最新的迁移应用于目标数据库?
dotnet tool install --global dotnet-ef
,但是在运行数据库更新时仍然出现错误。 - Waldemar工具'dotnet-ef'(版本'3.1.0')已成功安装。 运行“dotnet tool restore”以使“dotnet-ef”命令可用。
因此,我添加了“dotnet tool restore”并解决了问题。 - Waldemar