Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

480
Visualizações
Updating postgreSQL DB through EFCore migrations in Azure DevOps

In Azure DevOps, the way I used to update the SQL Server Database was with Entity Framework Core, using two tasks:

  1. In my Build Pipeline: This task that generated a sql script with my db migrations.
  2. In the Release Pipeline: This task to update the database using this script.

The thing is, now that I'm using a PostgreSQL database, I can't find an easy and clean way to update the database in the same way. I've seen there's another task for MySQL that does exactly the same my release pipeline task did with SQL Server, but nothing for PostgreSQL.

So I thought I could basically execute dotnet ef update database (with its proper options set) in the pipeline, but I was wondering if there's actually a way to keep updating the database in a smooth way as I did before.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I finally got to fix it.

There are two solutions I found to fix the issue.

  1. First, there's a common fix for all the databases that support Entity Framework Migrations:
    • Using a .NET Core Task, we'll have to install the dotnet ef tool: The task would look like this:

Intalling dotnet ef tools

And this would be the YAML (in case you want to use it in out of the release pipeline):

 - task: DotNetCoreCLI@2
  displayName: 'dotnet custom'
  inputs:
    command: custom
    custom: tool
    arguments: 'install --global dotnet-ef --version 3.1.4 --ignore-failed-sources'
  • And once we have the required tools installed, with a CMD or a Bash Task, we'll have to execute a script like this:
dotnet ef database update -c <DBCONTEXT> -p <PROJECT> -s <STARTUP_PROJECT> -v --no-build

You just have to add the flag -c in case you have more than one context in your project (sometimes the other DbContexts can come from some nugget packages).

Notice I added the flag --no-build since I already built the project in the build pipeline to follow good practices.


  1. The other option (and the one I finally used), it's been to use this task that basically does the same process, with the difference that it does it by using your already compiled .dll files, so you won't have to copy the entire project to make the migrations work. The setup of the task, although you have to fill many inputs, it's pretty straightforward, and it's supposed to work with other Databases as well.

However, if I had to use SQL Server or MySQL I would use a migrations script, since the process it's much easier (you just need to generate a .sql script and then it's the only file required for deploying the migrations).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda