zoukankan      html  css  js  c++  java
  • 【Azure DevOps系列】Azure DevOps构建.NET EFCore应用程序

    本章我们将看到如何通过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执行中更新到我们的数据库中,但是如上这种操作我不建议在生产环境中进行使用。

  • 相关阅读:
    程序猿和产品狗
    编写一个友元函数,求两个日期之间相差的天数
    集合的模拟实现(类模板)
    友元很简单2016final
    攻防世界-parallel-comparator-200
    web-GXYCTF2019 StrongestMind
    破解010Editor
    2020第三届江西省高校网络安全技能大赛线下解题赛部分wp
    pwn-EasyHeap(House of spirit)
    web-2020 ciscn littlegame(原型链污染)
  • 原文地址:https://www.cnblogs.com/yyfh/p/14827700.html
Copyright © 2011-2022 走看看