src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/gui/WizardPageDbConfig.cs
// <summary>
//     Changes connection string to point to new file path
// </summary>
// <param name="newFilePath">New file path</param>
// <returns>whether successful</returns>
Changes connection string to point to new file path
Changes connection string to point to new file path
private bool RetargetConnectionString(string newFilePath)
        {
            var filePathKey = LocalDataUtil.GetFilePathKey(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName,
                Wizard.ModelBuilderSettings.DesignTimeConnectionString);
            var newConnectionString = ConvertConnectionStringToNewPath(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName, filePathKey,
                Wizard.ModelBuilderSettings.DesignTimeConnectionString, newFilePath, false);
            var newAppConfigConnectionString = ConvertConnectionStringToNewPath(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName, filePathKey,
                Wizard.ModelBuilderSettings.AppConfigConnectionString, newFilePath, true);
            var oldProvider = DataConnectionUtils.GetVsProvider(_dataProviderManager, _dataConnection);
            if (null == oldProvider)
            {
                Debug.Fail("Could not find VS Provider for DataConnection " + _dataConnection.DisplayConnectionString);
                return false;
            }
            if (null == _dataConnectionManager)
            {
                Debug.Fail("this._dataConnectionManager is null - cannot construct new DataConnection");
                return false;
            }
            var dataConnection = _dataConnectionManager.GetConnection(oldProvider.Guid, newConnectionString, false);
            if (null == dataConnection)
            {
                Debug.Fail(
                    "DataConnectionManager could not get a connection for provider " + oldProvider.Guid + ", newConnectionString "
                    + newConnectionString);
                return false;
            }
            SetDataConnection(dataConnection);
            var currentDataSourceComboBoxItem = dataSourceComboBox.SelectedItem as DataSourceComboBoxItem;
            Debug.Assert(null != currentDataSourceComboBoxItem, "Currently selected should not be null");
            if (null != currentDataSourceComboBoxItem)
            {
                currentDataSourceComboBoxItem.ResetDataConnection(dataConnection);
            }
            Wizard.ModelBuilderSettings.SetInvariantNamesAndConnectionStrings(ServiceProvider,
                Wizard.Project, Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName, newConnectionString,
                newAppConfigConnectionString, true);
            return true;
        }
private bool RetargetConnectionString ( string newFilePath ) { var filePathKey = LocalDataUtil . GetFilePathKey ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , Wizard . ModelBuilderSettings . DesignTimeConnectionString ) ; var newConnectionString = ConvertConnectionStringToNewPath ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , filePathKey , Wizard . ModelBuilderSettings . DesignTimeConnectionString , newFilePath , false ) ; var newAppConfigConnectionString = ConvertConnectionStringToNewPath ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , filePathKey , Wizard . ModelBuilderSettings . AppConfigConnectionString , newFilePath , true ) ; var oldProvider = DataConnectionUtils . GetVsProvider ( _dataProviderManager , _dataConnection ) ; if ( null == oldProvider ) { Debug . Fail ( " " + _dataConnection . DisplayConnectionString ) ; return false ; } if ( null == _dataConnectionManager ) { Debug . Fail ( " " ) ; return false ; } var dataConnection = _dataConnectionManager . GetConnection ( oldProvider . Guid , newConnectionString , false ) ; if ( null == dataConnection ) { Debug . Fail ( " " + oldProvider . Guid + " " + newConnectionString ) ; return false ; } SetDataConnection ( dataConnection ) ; var currentDataSourceComboBoxItem = dataSourceComboBox . SelectedItem as DataSourceComboBoxItem ; Debug . Assert ( null != currentDataSourceComboBoxItem , " " ) ; if ( null != currentDataSourceComboBoxItem ) { currentDataSourceComboBoxItem . ResetDataConnection ( dataConnection ) ; } Wizard . ModelBuilderSettings . SetInvariantNamesAndConnectionStrings ( ServiceProvider , Wizard . Project , Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , newConnectionString , newAppConfigConnectionString , true ) ; return true ; }
Changes connection string to point to new file path
Changes connection string to point to new file path
// compute the Design and Runtime Connection String values based on the new file path // Note: newAppConfigConnectionString should use the |DataDirectory| macro because // that is what's displayed on screen and interpreted at runtime, but newConnectionString // should not use the macro as it will be used by the wizard at the next step to create // a working DB connection // update the DataConnection itself with the new path // update this WizardPage's DataConnection and also set the DataSourceComboBoxItem's  // dataConnection to this so that this connection is used if the user re-selects this // item from the drop-down // update the Design and Runtime Connection String values stored in ModelBuilderSettings // these connection strings & invariant names are coming from the ddex provider, so these are "design-time"
None
newFilePath
string
New file path
New file path