src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/gui/WizardPageStart.cs
// <summary>
//     Helper to update ModelBuilderSettings from listbox selection
// </summary>
Helper to update ModelBuilderSettings from listbox selection
Helper to update ModelBuilderSettings from listbox selection
private void UpdateSettingsFromGui(int selectedOptionIndex, string modelPath)
        {
            Wizard.ModelBuilderSettings.ModelPath = modelPath;
            if (selectedOptionIndex == GenerateEmptyModelIndex)
            {
                Debug.Assert(
                    Wizard.ModelBuilderSettings.GenerationOption == ModelGenerationOption.EmptyModel, 
                    "Generation option not updated correctly");
                Wizard.ModelBuilderSettings.ModelBuilderEngine = null;
                LazyInitialModelContentsFactory.AddSchemaSpecificReplacements(
                    Wizard.ModelBuilderSettings.ReplacementDictionary,
                    Wizard.ModelBuilderSettings.TargetSchemaVersion);
            }
            else if (selectedOptionIndex == GenerateFromDatabaseIndex)
            {
                Debug.Assert(
                    Wizard.ModelBuilderSettings.GenerationOption == ModelGenerationOption.GenerateFromDatabase,
                    "Generation option not updated correctly");
                Debug.Assert(Wizard.ModelBuilderSettings.VsTemplatePath != null, "Invalid vstemplate path.");
                Wizard.ModelBuilderSettings.ModelBuilderEngine =
                    new EdmxModelBuilderEngine(
                        new LazyInitialModelContentsFactory(
                            GetEdmxTemplateContent(Wizard.ModelBuilderSettings.VsTemplatePath),
                            Wizard.ModelBuilderSettings.ReplacementDictionary));
            }
            else if (selectedOptionIndex == GenerateCodeFirstFromDatabaseIndex)
            {
                Debug.Assert(
                    Wizard.ModelBuilderSettings.GenerationOption == ModelGenerationOption.CodeFirstFromDatabase,
                    "Generation option not updated correctly");
                Wizard.ModelBuilderSettings.ModelBuilderEngine = new CodeFirstModelBuilderEngine();
            }
            else
            {
                Debug.Assert(selectedOptionIndex == GenerateEmptyModelCodeFirstIndex, "Unexpected index.");
                Debug.Assert(
                    (Wizard.ModelBuilderSettings.GenerationOption == ModelGenerationOption.EmptyModelCodeFirst
                     && selectedOptionIndex == GenerateEmptyModelCodeFirstIndex),
                    "Generation option not updated correctly");
                Wizard.ModelBuilderSettings.ModelBuilderEngine = null;
                Wizard.ModelBuilderSettings.AppConfigConnectionPropertyName =
                    ConnectionManager.GetUniqueConnectionStringName(
                        _configFileUtils, Wizard.ModelBuilderSettings.ModelName);
                var initialCatalog = string.Format(
                    CultureInfo.CurrentCulture,
                    "{0}.{1}", 
                    Wizard.ModelBuilderSettings.ReplacementDictionary["$rootnamespace$"], 
                    Wizard.ModelBuilderSettings.ModelName);
                Wizard.ModelBuilderSettings.SaveConnectionStringInAppConfig = true;
                var defaultConnectionString =
                    ConnectionManager.CreateDefaultLocalDbConnectionString(initialCatalog);
                Wizard.ModelBuilderSettings.SetInvariantNamesAndConnectionStrings(
                    ServiceProvider, Wizard.Project, ConnectionManager.SqlClientProviderName,
                    defaultConnectionString, defaultConnectionString, isDesignTime: false);
            }
        }
private void UpdateSettingsFromGui ( int selectedOptionIndex , string modelPath ) { Wizard . ModelBuilderSettings . ModelPath = modelPath ; if ( selectedOptionIndex == GenerateEmptyModelIndex ) { Debug . Assert ( Wizard . ModelBuilderSettings . GenerationOption == ModelGenerationOption . EmptyModel , " " ) ; Wizard . ModelBuilderSettings . ModelBuilderEngine = null ; LazyInitialModelContentsFactory . AddSchemaSpecificReplacements ( Wizard . ModelBuilderSettings . ReplacementDictionary , Wizard . ModelBuilderSettings . TargetSchemaVersion ) ; } else if ( selectedOptionIndex == GenerateFromDatabaseIndex ) { Debug . Assert ( Wizard . ModelBuilderSettings . GenerationOption == ModelGenerationOption . GenerateFromDatabase , " " ) ; Debug . Assert ( Wizard . ModelBuilderSettings . VsTemplatePath != null , " " ) ; Wizard . ModelBuilderSettings . ModelBuilderEngine = new EdmxModelBuilderEngine ( new LazyInitialModelContentsFactory ( GetEdmxTemplateContent ( Wizard . ModelBuilderSettings . VsTemplatePath ) , Wizard . ModelBuilderSettings . ReplacementDictionary ) ) ; } else if ( selectedOptionIndex == GenerateCodeFirstFromDatabaseIndex ) { Debug . Assert ( Wizard . ModelBuilderSettings . GenerationOption == ModelGenerationOption . CodeFirstFromDatabase , " " ) ; Wizard . ModelBuilderSettings . ModelBuilderEngine = new CodeFirstModelBuilderEngine ( ) ; } else { Debug . Assert ( selectedOptionIndex == GenerateEmptyModelCodeFirstIndex , " " ) ; Debug . Assert ( ( Wizard . ModelBuilderSettings . GenerationOption == ModelGenerationOption . EmptyModelCodeFirst && selectedOptionIndex == GenerateEmptyModelCodeFirstIndex ) , " " ) ; Wizard . ModelBuilderSettings . ModelBuilderEngine = null ; Wizard . ModelBuilderSettings . AppConfigConnectionPropertyName = ConnectionManager . GetUniqueConnectionStringName ( _configFileUtils , Wizard . ModelBuilderSettings . ModelName ) ; var initialCatalog = string . Format ( CultureInfo . CurrentCulture , " " , Wizard . ModelBuilderSettings . ReplacementDictionary [ " " ] , Wizard . ModelBuilderSettings . ModelName ) ; Wizard . ModelBuilderSettings . SaveConnectionStringInAppConfig = true ; var defaultConnectionString = ConnectionManager . CreateDefaultLocalDbConnectionString ( initialCatalog ) ; Wizard . ModelBuilderSettings . SetInvariantNamesAndConnectionStrings ( ServiceProvider , Wizard . Project , ConnectionManager . SqlClientProviderName , defaultConnectionString , defaultConnectionString , isDesignTime : false ) ; } }
Helper to update ModelBuilderSettings from listbox selection
Helper to update ModelBuilderSettings from listbox selection
// for CodeFirst empty model we always add a localdb connection
selectedOptionIndex
int
modelPath
string