public virtual void GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils = null, ModelBuilderEngineHostContext hostContext = null) { if (settings.GenerationOption == ModelGenerationOption.GenerateFromDatabase && String.IsNullOrEmpty(settings.DesignTimeConnectionString)) { throw new ArgumentOutOfRangeException(Resources.Engine_EmptyConnStringErrorMsg); } var generatingModelWatch = Stopwatch.StartNew(); hostContext = hostContext ?? new VSModelBuilderEngineHostContext(settings); vsUtils = vsUtils ?? new VsUtilsWrapper(); // Clear out the ModelGenErrorCache before ModelGen begins PackageManager.Package.ModelGenErrorCache.RemoveErrors(settings.ModelPath); var errors = new List <EdmSchemaError>(); try { var storeModelNamespace = GetStoreNamespace(settings); Model = GenerateModels(storeModelNamespace, settings, errors); ProcessModel(Model, storeModelNamespace, settings, hostContext, errors); hostContext.LogMessage( FormatMessage( errors.Any() ? Resources.Engine_ModelGenErrors : Resources.Engine_ModelGenSuccess, Path.GetFileName(settings.ModelPath))); if (errors.Any()) { PackageManager.Package.ModelGenErrorCache.AddErrors(settings.ModelPath, errors); } } catch (Exception e) { hostContext.LogMessage(FormatMessage(Resources.Engine_ModelGenException, e)); // The exception we re-throw will get swallowed in the message pump and therefore we need to show the message box here. // It will also prevent the form.WizardFinished from being set to true which will cause cancelling the wizard and // therefore block adding new project items to the project as well as ModelObjectItemWizardFrom.RunFinished method. vsUtils.ShowErrorDialog(FormatMessage(Resources.Engine_ModelGenExceptionMessageBox, e.GetType().Name, e.Message)); throw; } finally { generatingModelWatch.Stop(); hostContext.LogMessage(FormatMessage(Resources.LoadingDBMetadataTimeMsg, settings.LoadingDBMetadataTime)); hostContext.LogMessage(FormatMessage(Resources.GeneratingModelTimeMsg, generatingModelWatch.Elapsed)); } }
public virtual void GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils = null, ModelBuilderEngineHostContext hostContext = null) { if (settings.GenerationOption == ModelGenerationOption.GenerateFromDatabase && String.IsNullOrEmpty(settings.DesignTimeConnectionString)) { throw new ArgumentOutOfRangeException(Resources.Engine_EmptyConnStringErrorMsg); } var generatingModelWatch = Stopwatch.StartNew(); hostContext = hostContext ?? new VSModelBuilderEngineHostContext(settings); vsUtils = vsUtils ?? new VsUtilsWrapper(); // Clear out the ModelGenErrorCache before ModelGen begins PackageManager.Package.ModelGenErrorCache.RemoveErrors(settings.ModelPath); var errors = new List<EdmSchemaError>(); try { var storeModelNamespace = GetStoreNamespace(settings); Model = GenerateModels(storeModelNamespace, settings, errors); ProcessModel(Model, storeModelNamespace, settings, hostContext, errors); hostContext.LogMessage( FormatMessage( errors.Any() ? Resources.Engine_ModelGenErrors : Resources.Engine_ModelGenSuccess, Path.GetFileName(settings.ModelPath))); if (errors.Any()) { PackageManager.Package.ModelGenErrorCache.AddErrors(settings.ModelPath, errors); } } catch (Exception e) { hostContext.LogMessage(FormatMessage(Resources.Engine_ModelGenException, e)); // The exception we re-throw will get swallowed in the message pump and therefore we need to show the message box here. // It will also prevent the form.WizardFinished from being set to true which will cause cancelling the wizard and // therefore block adding new project items to the project as well as ModelObjectItemWizardFrom.RunFinished method. vsUtils.ShowErrorDialog(FormatMessage(Resources.Engine_ModelGenExceptionMessageBox, e.GetType().Name, e.Message)); throw; } finally { generatingModelWatch.Stop(); hostContext.LogMessage(FormatMessage(Resources.LoadingDBMetadataTimeMsg, settings.LoadingDBMetatdataTime)); hostContext.LogMessage(FormatMessage(Resources.GeneratingModelTimeMsg, generatingModelWatch.Elapsed)); } }
internal virtual void GenerateModel(EdmxHelper edmxHelper, ModelBuilderSettings settings, ModelBuilderEngineHostContext hostContext) { var generatingModelWatch = Stopwatch.StartNew(); // Clear out the ModelGenErrorCache before ModelGen begins PackageManager.Package.ModelGenErrorCache.RemoveErrors(settings.ModelPath); var errors = new List <EdmSchemaError>(); try { var storeModelNamespace = GetStoreNamespace(settings); var model = GenerateModels(storeModelNamespace, settings, errors); edmxHelper.UpdateEdmxFromModel(model, storeModelNamespace, settings.ModelNamespace, errors); // load extensions that want to update model after the wizard has run. hostContext.DispatchToModelGenerationExtensions(); UpdateDesignerInfo(edmxHelper, settings); hostContext.LogMessage( FormatMessage( errors.Any() ? Resources.Engine_ModelGenErrors : Resources.Engine_ModelGenSuccess, Path.GetFileName(settings.ModelPath))); if (errors.Any()) { PackageManager.Package.ModelGenErrorCache.AddErrors(settings.ModelPath, errors); } } catch (Exception e) { hostContext.LogMessage(FormatMessage(Resources.Engine_ModelGenException, e)); } generatingModelWatch.Stop(); hostContext.LogMessage(FormatMessage(Resources.LoadingDBMetadataTimeMsg, settings.LoadingDBMetatdataTime)); hostContext.LogMessage(FormatMessage(Resources.GeneratingModelTimeMsg, generatingModelWatch.Elapsed)); }