如何使用Azure DevOps构建.NET EFCore应用程序?

摘要:本章我们将看到如何通过Azure DevOps使用EFCore CLI工具将我们的EFCore应用程序进行数据库重建,当然这种操作我不建议使用,建议使用CLI生成sql脚本形式进行发布并迁移。 设置代理服务器sdk - task: UseD
本章我们将看到如何通过Azure DevOps使用EFCore CLI工具将我们的EFCore应用程序进行数据库重建,当然这种操作我不建议使用,建议使用CLI生成sql脚本形式进行发布并迁移。 设置代理服务器sdk - task: UseDotNet@2 inputs: packageType: 'sdk' version: '3.x' 安装dotnet-ef 安装Entity Framework Core CLI工具,用于后面对数据库的操作 - task: CmdLine@2 displayName: 'install dotnet-ef' inputs: script: 'dotnet tool install -g dotnet-ef' 删除数据库 dotnet ef database drop --project <path to your csproj with drop> -f 选项 Short 说明 --force -f 不要确认。 --dry-run row 2 col 2 显示要删除的数据库,但不删除它。 - task: CmdLine@2 displayName: 'drop database' inputs: script: | dotnet ef database drop --project host/EasyAbp.PrivateMessaging.Web.Unified/EasyAbp.PrivateMessaging.Web.Unified.csproj -f 更新数据库 将数据库更新为上一次迁移或指定的迁移。 dotnet ef database update --project <path to your csproj with update> - task: CmdLine@2 displayName: 'update database' inputs: script: | dotnet ef database update --project host/EasyAbp.PrivateMessaging.Web.Unified/EasyAbp.PrivateMessaging.Web.Unified.csproj 通过如上过程我们便可以将数据库在pipeline执行中更新到我们的数据库中,但是如上这种操作我不建议在生产环境中进行使用。