Tuesday 4 January 2022

How to add the last version of LocalDB to Azure Devops Pipeline

How to add the last version of LocalDB to Azure Devops Pipeline

1. Add [Command line] Step to Pipeline and name it "Upgrade LocalDB"
2. Add this commands to the new step:
SqlLocalDB stop
SqlLocalDB delete
choco upgrade sqllocaldb
SqlLocalDB create
SqlLocalDB start
SqlLocalDB share MSSQLLocalDB MSSQLLocalDB
SqlLocalDB info MSSQLLocalDB
SQLCMD.EXE -S (localdb)\MSSQLLocalDB -Q "SELECT @@VERSION;"

Known issues:
In some cases the .NET Code cannot connect the LocalDB.
If LocalDB is used in .NET Core Services, then add EnableRetryOnFailure to UseSqlServer call