private void StartComparison() { ProgressForm progress = null; string errorLocation = null; try { if ((!String.IsNullOrEmpty(ProjectSelectorHandler.GetSourceDatabaseName()) && (!String.IsNullOrEmpty(ProjectSelectorHandler.GetDestinationDatabaseName())))) { Options = Options ?? this.ProjectSelectorHandler.GetDefaultProjectOptions(); var leftGenerator = this.ProjectSelectorHandler.SetSourceGenerator(LeftDatabaseSelector.ConnectionString, Options); var rightGenerator = this.ProjectSelectorHandler.SetDestinationGenerator(RightDatabaseSelector.ConnectionString, Options); IDatabaseComparer databaseComparer = this.ProjectSelectorHandler.GetDatabaseComparer(); var leftPair = new KeyValuePair <String, IGenerator>(LeftDatabaseSelector.ToString(), leftGenerator); var rightPair = new KeyValuePair <String, IGenerator>(RightDatabaseSelector.ToString(), rightGenerator); // The progress form will execute the comparer to generate action scripts to migrate the right to the left // Hence, inside the ProgressForm and deeper, right is the origin and left is the destination progress = new ProgressForm(rightPair, leftPair, databaseComparer); progress.ShowDialog(this); if (progress.Error != null) { throw new SchemaException(progress.Error.Message, progress.Error); } txtSyncScript.LexerLanguage = this.ProjectSelectorHandler.GetScriptLanguage(); txtSyncScript.ReadOnly = false; errorLocation = "Generating Synchronized Script"; txtSyncScript.Text = progress.Destination.ToSqlDiff(this._selectedSchemas).ToSQL(); txtSyncScript.ReadOnly = true; txtSyncScript.SetMarginWidth(); // Notice again that left is destination, because we generated scripts to migrate the right database to the left. schemaTreeView1.LeftDatabase = progress.Destination; schemaTreeView1.RightDatabase = progress.Origin; schemaTreeView1.OnSelectItem += new SchemaTreeView.SchemaHandler(schemaTreeView1_OnSelectItem); schemaTreeView1_OnSelectItem(schemaTreeView1.SelectedNode); textBox1.Text = progress.Origin.ActionMessage.Message; btnCopy.Enabled = true; btnSaveAs.Enabled = true; btnUpdateAll.Enabled = true; } else { MessageBox.Show(Owner, "Please select a valid connection string", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { if (errorLocation == null && progress != null) { errorLocation = String.Format("{0} (while {1})", progress.ErrorLocation, progress.ErrorMostRecentProgress ?? "initializing"); } throw new SchemaException("Error " + (errorLocation ?? " Comparing Databases"), ex); } }