private void InitializeDiagram() { var diagram = GetCurrentDiagram(this.Store); if (!diagram.Initialized) { // Display a form to the user. The form collects // input for initializing the diagram. var dlg = new ItemDetailsForm(); dlg.ShowDialog(); var data = dlg.GetInitializeData(); ModelerTransaction.Enter(() => { using (var tx = diagram.Store.TransactionManager.BeginTransaction("Initialize", false)) { (diagram.ModelElement as ModelRoot).DataContextName = data.ContextName; diagram.Initialized = true; if (tx.HasPendingChanges) { tx.Commit(); } } if (data.ImportFromDatabase) { ConnectionUtil.SetExistingConnection(diagram.ModelElement as ModelRoot); var sync = new Utilities.DbSchemaImporter(diagram); sync.ImportModels(); } else { ConnectionUtil.GetOrCreateConnectionString(diagram.ModelElement as ModelRoot, diagram.Name); } }); } }