Janniks Blog

Using SQL Server Express LocalDB in Azure DevOps

October 03, 2019

Actually it is quite easy to use SQL Server Express LocalDB in Azure DevOps. The service just needs to be started with a command line (i.e. using the Powershell task):

- task: PowerShell@2
  displayName: 'start mssqllocaldb'
  inputs:
    targetType: 'inline'
    script: 'sqllocaldb start mssqllocaldb'

In all subsequent tasks, the database engine can be used. I.e. following connection string is valid:

Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=my-db;Integrated Security=True;

Notes on Entity Framework Core and Inmemory DB provider

You probably want to make use of MS SQL Local DB if you are target MS SQL Server and need to do some integration testing in Azure DevOps. Microsoft also provides us with an InMemory database provider for test scenarios. However this provider has several limitations which limit its applicability (i.e. its not a relational database). The behavioral difference to MS SQL Server is to big in many cases, whereas with LocalDB its not. That makes it ideal for integration tests.