diff --git a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs index 5089168f..25187aca 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.IO; +using System.Threading; using Microsoft.SqlServer.Dac; using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts; @@ -51,6 +52,9 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx this.SqlTask.AddScript(SqlTaskStatus.Succeeded, Result.DatabaseScript); if (!string.IsNullOrEmpty(this.Result.MasterDbScript)) { + // Delay to avoid race condition to ensure both scripts get opened in ADS. Fix for https://github.com/microsoft/azuredatastudio/issues/20133 + Thread.Sleep(500); + // master script is only used if the target is Azure SQL db and the script contains all operations that must be done against the master database this.SqlTask.AddScript(SqlTaskStatus.Succeeded, this.Result.MasterDbScript); }