Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

so I have a question regarding running integration test project in Azure DevOps build pipeline. My solution has common EF Core Code-First approach with migrations and when I run the tests, it executes Migrate() method from EF Core which either creates a new DB with latest migrations or applies new migrations if available.

What I have tried:

So I setup build pipeline for solution including xUnit project targeting Core 3.1 (tested API is also Core 3.1) with hardcoded localDb connection string (the one used locally with MS SQL Express for integration tests) and to my surprise, it works out of the box and all the tests PASS? But I can't find any log regarding creating the DB and applying migrations and that seems fishy to me. Obviously it works locally but doesn't it require to create some step to start the SQL DB available in windows-2019 agent? Or is that normal and it should work just like it works locally without any other setup?

The available software for the agent has sql express available so I guess there's a chance that it works just like locally:
Version: 15.0.4538.1
    SQL Server Express LocalDB is available at C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe


Anyone can confirm?
Posted
Updated 26-Jan-22 4:39am
v2

1 solution

I realize this extraordinarily late to the game, but I came across this blog post that demonstrates using a task in a pipeline yaml file to start the service on a Windows hosted agent: http://jannikbuschke.de/blog/azure-devops-enable-mssqllocaldb/[^]

Basically it's this task:
- task: PowerShell@2
  displayName: 'start mssqllocaldb'
  inputs:
    targetType: 'inline'
    script: 'sqllocaldb start mssqllocaldb'


On a Linux hosted agent, only MS SQL tools are available, it would probably be best to use a custom Docker container with SQL Server for Linux (Express) and the Azure DevOps agent.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900