protected override void PostInvoke(CommandProcessorContext cpc) { base.PostInvoke(cpc); if (_settings.HasExtensionChangedModel) { // // we validate here in the command so that we can throw to abort the transaction on errors // // // since the xml editor transaction hasn't been committed, the model state isn't totally valid and we get // a bunch of assertions if we use the model backed by the xml editor. For example, if we try to validate, // we get assertions about being unable to find line numbers. Because of this, we create a temporary artifact // on the updated model and validate that. // EntityDesignModelManager tempModelManager = null; EFArtifact tempArtifact = null; InMemoryXmlModelProvider modelProvider = null; try { var uri = _artifact.Uri; modelProvider = new InMemoryXmlModelProvider(uri, _artifact.XDocument.ToString()); // NOTE: use an EFArtifact with VSArtifactSet. This is so we get the in-vs behavior of artifact sets, but don't rely on VS loading the model into the RDT, etc.. // We passed in instance of EFArtifactFactory to the model manager because we don't want the DiagramArtifact is instantiated and loaded because: // - We are only interested in Model validation; there is no need to load diagram. // - InMemoryXmlModelProvider will throw when we request to load diagram model since diagram model URI is different from entity model URI. tempModelManager = new EntityDesignModelManager(new EFArtifactFactory(), new VSArtifactSetFactory()); tempArtifact = tempModelManager.GetNewOrExistingArtifact(uri, modelProvider); ValidateArtifact(tempModelManager, tempArtifact, WizardKind.UpdateModel); } finally { if (tempArtifact != null) { tempArtifact.Dispose(); } if (tempModelManager != null) { tempModelManager.Dispose(); } if (modelProvider != null) { modelProvider.Dispose(); } } } }