diff --git a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts index d35a0f54f0..14337cc54e 100644 --- a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts +++ b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts @@ -88,7 +88,7 @@ export class SchemaCompareDialog { // connection to use if schema compare wasn't launched from a database or no previous source/target let connection = await azdata.connection.getCurrentConnection(); if (connection) { - this.connectionId = connection.connectionId; + this.connectionId = connection.connectionId; // current active connection } this.dialog = azdata.window.createModelViewDialog(loc.SchemaCompareLabel); @@ -874,13 +874,12 @@ export class SchemaCompareDialog { finalName = c.options.connectionName; } - // use previously selected server or current connection if there is one - if (endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName) - && c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase() - && finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase()) { - idx = count; - } - else if (c.connectionId === this.connectionId) { + // use current connection else use previously selected server if there is one + if ((c.connectionId === this.connectionId) || + (endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName) + && c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase() + && finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase() + && idx === -1)) { // select previous server only if current connection hasn't been set already idx = count; }