/* This callbacks only appears to be called by the Update Wizard*/
        /// <summary>
        /// Called when the selected object in the Entity Data Model Designer changes
        /// and matches the specified EntityDesignerExtendedProperty attribute.
        /// </summary>
        /// <param name="context"></param>
        void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context)
        {
            //
            // 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.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or
            //                             the Update Model Wizard. An extension cannot modify this document.
            //
            // 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 generated from the database by the '{1}' wizard.\n\n",
                efv4ModelOrLater ? 4 : 3.5,
                context.WizardKind == WizardKind.Generate ? "Create Model" : "Update Model From Database");

            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 generated model.";
            }

            MessageBox.Show(message, caption);
        }
 protected override void DispatchToSingleExtension(IModelGenerationExtension extension, ModelGenerationExtensionContext context)
 {
     var umfdbContext = context as UpdateModelExtensionContext;
     Debug.Assert(umfdbContext != null, "Unexpected type of context!");
     if (context != null)
     {
         extension.OnAfterModelUpdated(umfdbContext);
     }
 }
        /* This callbacks only appears to be called by the Update Wizard*/

        /// <summary>
        /// Called when the selected object in the Entity Data Model Designer changes
        /// and matches the specified EntityDesignerExtendedProperty attribute.
        /// </summary>
        /// <param name="context">Provides file and Visual Studio project information.</param>
        void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context)
        {
            //
            // 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.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or 
            //                             the Update Model Wizard. An extension cannot modify this document.
            //
            // 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.
            //

        }
 public void OnAfterModelGenerated(ModelGenerationExtensionContext context)
 {
     return;
 }
 protected virtual void DispatchToSingleExtension(IModelGenerationExtension extension, ModelGenerationExtensionContext context)
 {
     extension.OnAfterModelGenerated(context);
 }
        /// <summary>
        /// Called after an .edmx document is generated by the Entity Data Model Wizard or the Update Model Wizard.
        /// </summary>
        /// <param name="context">
        /// 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.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or the Update Model Wizard.
        ///                             An extension cannot modify this document.
        /// 
        /// 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.
        /// </param>
        public void OnAfterModelGenerated(ModelGenerationExtensionContext context)
        {
            // Capture any model errors that were NOT created by this extension.
            _edmxErrors = _errorList.Where(error =>
                                    error.FileName.EndsWith(".edmx") &&
                                    error.Description.StartsWith("Error") &&
                                    error.Project == context.Project.UniqueName).ToList();

            // When in Update mode, both methods will be called and only one of them needs to execute.
            if (context.WizardKind == WizardKind.Generate)
                UpdateModel(context.Project, context.CurrentDocument, context.WizardKind);
        }