src/Misc/EFTools/EntityDesign/VisualStudio/Package/ConnectionManager.cs
// <summary>
//     Change the entity container name in the hash, then rewrite the .config file.
// </summary>
// <param name="project">DTE Project that owns the .config file</param>
// <param name="oldName"></param>
// <param name="newName"></param>
Change the entity container name in the hash, then rewrite the .config file.
Change the entity container name in the hash then rewrite the . config file .
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1614:ElementParameterDocumentationMustHaveText")]
        internal void UpdateEntityContainerName(Project project, string oldName, string newName)
        {
            if (null == project)
            {
                throw new ArgumentNullException("project");
            }
            if (project.UniqueName.Equals(Constants.vsMiscFilesProjectUniqueName, StringComparison.Ordinal))
            {
                return;
            }
            if (String.IsNullOrEmpty(oldName))
            {
                throw new ArgumentNullException("oldName");
            }
            if (String.IsNullOrEmpty(newName))
            {
                throw new ArgumentNullException("newName");
            }
            lock (_hashSyncRoot)
            {
                ExtractConnStringsIntoHash(project, true);
                ConnectionString tempString = null;
                if (ConnStringsByProjectHash.ContainsKey(project)
                    && ConnStringsByProjectHash[project].TryGetValue(oldName, out tempString))
                {
                    ConnStringsByProjectHash[project].Remove(oldName);
                    if (ConnStringsByProjectHash[project].ContainsKey(newName))
                    {
                        ConnStringsByProjectHash[project].Remove(newName);
                    }
                    ConnStringsByProjectHash[project].Add(newName, tempString);
                    InsertConnStringsFromHash(project);
                }
            }
        }
[ SuppressMessage ( " " , " " ) ] internal void UpdateEntityContainerName ( Project project , string oldName , string newName ) { if ( null == project ) { throw new ArgumentNullException ( " " ) ; } if ( project . UniqueName . Equals ( Constants . vsMiscFilesProjectUniqueName , StringComparison . Ordinal ) ) { return ; } if ( String . IsNullOrEmpty ( oldName ) ) { throw new ArgumentNullException ( " " ) ; } if ( String . IsNullOrEmpty ( newName ) ) { throw new ArgumentNullException ( " " ) ; } lock ( _hashSyncRoot ) { ExtractConnStringsIntoHash ( project , true ) ; ConnectionString tempString = null ; if ( ConnStringsByProjectHash . ContainsKey ( project ) && ConnStringsByProjectHash [ project ] . TryGetValue ( oldName , out tempString ) ) { ConnStringsByProjectHash [ project ] . Remove ( oldName ) ; if ( ConnStringsByProjectHash [ project ] . ContainsKey ( newName ) ) { ConnStringsByProjectHash [ project ] . Remove ( newName ) ; } ConnStringsByProjectHash [ project ] . Add ( newName , tempString ) ; InsertConnStringsFromHash ( project ) ; } } }
Change the entity container name in the hash, then rewrite the .config file.
Change the entity container name in the hash then rewrite the . config file .
// there definitely has to be a connection string keyed by the old entity container name. // if the user opens up a .config with connection strings that aren't being used, one of them // could contain the new entity container name, so we make sure we remove that before adding.
project
Project
DTE Project that owns the .config file
DTE Project that owns the . config file
oldName
string
None
newName
string
None