/// <summary> /// Called after a model is updated by the Update Model Wizard. /// </summary> /// <param name="context">Provides file information and Visual Studio project information.</param> void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) { // // context.OriginalDocument = The original XDocument before the Update Model Wizard started. // An extension cannot modify this document. // // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. // An extension cannot modify this document. // // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the // contents of context.GeneratedDocument. An extension cannot modify this document. // // context.CurrentDocument = The XDocument that will be saved. An extension can modify this // document. Note that the document may have been modified by another extension's implementation // of OnAfterModelGenerated(). // // // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. // // context.Project = The EnvDTE.Project that contains the .edmx file. // // context.WizardKind = The wizard that initiated the .edmx file generation or update process. // Possible values are WizardKind.Generate or WizardKind.UpdateModel. // }
/// <summary> /// Called after a model is updated by the Update Model Wizard. /// </summary> /// <param name="context"></param> void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) { // // context.OriginalDocument = The original XDocument before the Update Model Wizard started. // An extension cannot modify this document. // // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. // An extension cannot modify this document. // // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the // contents of context.GeneratedDocument. An extension cannot modify this document. // // context.CurrentDocument = The XDocument that will be saved. An extension can modify this // document. Note that the document may have been modified by another extension's implementation // of OnAfterModelGenerated(). // // // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. // // context.Project = The EnvDTE.Project that contains the .edmx file. // // context.WizardKind = The wizard that initiated the .edmx file generation or update process. // Possible values are WizardKind.Generate or WizardKind.UpdateModel. // bool efv4ModelOrLater = IsEFv4ModelOrLater(context.Project); String caption = "OnAfterModelGenerated called"; String message = String.Format( "An EF v{0} model was updated from the database by the 'Update Model From Database' wizard.\n\n", efv4ModelOrLater ? 4 : 3.5); if (efv4ModelOrLater) { // Call helper method to add a new property to the generated EF v2 model. AddPropertyToModel(context.CurrentDocument); message += "Added a new property to EntityTypes in the updated model."; } MessageBox.Show(message, caption); }
public void OnAfterModelUpdated(UpdateModelExtensionContext context) { return; }
/// <summary> /// Called after a model is updated by the Update Model Wizard. /// Note: the Update Model Wizard generates a temporary .edmx document which is then merged with the existing document /// to produce the updated document. The OnAfterModelGenerated() method will be called on the temporary document before /// the merge process begins. This OnAfterModelUpdated() method allows you to make further changes to the document /// after it has been merged with the existing document. /// </summary> /// <param name="context"> /// context.OriginalDocument = The original XDocument before the Update Model Wizard started. /// An extension cannot modify this document. /// /// context.GeneratedDocument = The temporary XDocument that was generated by the Update Model wizard from the database. /// An extension cannot modify this document. /// /// context.UpdateModelDocument = The contents of context.OriginalDocument merged with the contents of context.GeneratedDocument. /// An extension cannot modify this document. /// /// context.CurrentDocument = The XDocument that will be saved. /// An extension can modify this document. Note that the document may have been modified by another extension's implementation of OnAfterModelUpdated(). /// /// context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. /// /// context.Project = The EnvDTE.Project that contains the .edmx file. /// /// context.WizardKind = The wizard that initiated the .edmx file generation or update process (WizardKind.UpdateModel). /// </param> public void OnAfterModelUpdated(UpdateModelExtensionContext context) { // Emit a warning if model errors already existed, particularly to avoid this extension getting blamed for them. if (_edmxErrors.Count > 0) _logger.Log("{0:yyyy-MM-dd HH:mm:ss:ffff}: Warning - Model contains errors prior to update. This plugin may erroneously be blamed for them.", DateTime.Now); UpdateModel(context.Project, context.CurrentDocument, context.WizardKind); }