Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

473
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!