src/Misc/EFTools/EntityDesign/VisualStudio/Package/ConnectionManager.cs
// <summary>
//     Injects the MARS/AppFramework attributes into the provider connection string
//     without pinging the connection to see if the database supports SQL 90 or newer. This
//     does not require a design-time connection.
// </summary>
Injects the MARS/AppFramework attributes into the provider connection string
without pinging the connection to see if the database supports SQL 90 or newer. This
does not require a design-time connection.
Injects the MARS / AppFramework attributes into the provider connection string without pinging the connection to see if the database supports SQL 90 or newer . This does not require a design - time connection .
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        internal static string InjectEFAttributesIntoConnectionString(string sourceConnectionString, string providerInvariantName)
        {
            if (!string.Equals(providerInvariantName, SqlClientProviderName, StringComparison.Ordinal))
            {
                return sourceConnectionString;
            }
            var configFileConnectionBuilder = new DbConnectionStringBuilder();
            try
            {
                configFileConnectionBuilder.ConnectionString = sourceConnectionString;
            }
            catch (ArgumentException)
            {
                return sourceConnectionString;
            }
            object marsValue;
            if (!configFileConnectionBuilder.TryGetValue(XmlAttrNameMultipleActiveResultSets, out marsValue))
            {
                configFileConnectionBuilder[XmlAttrNameMultipleActiveResultSets] = true.ToString();
            }
            if (!configFileConnectionBuilder.ContainsKey(ProviderConnectionStringPropertyNameApp)
                && !configFileConnectionBuilder.ContainsKey(ProviderConnectionStringPropertyNameApplicationName))
            {
                configFileConnectionBuilder[ProviderConnectionStringPropertyNameApp] = "EntityFramework";
            }
            return configFileConnectionBuilder.ConnectionString;
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] internal static string InjectEFAttributesIntoConnectionString ( string sourceConnectionString , string providerInvariantName ) { if ( ! string . Equals ( providerInvariantName , SqlClientProviderName , StringComparison . Ordinal ) ) { return sourceConnectionString ; } var configFileConnectionBuilder = new DbConnectionStringBuilder ( ) ; try { configFileConnectionBuilder . ConnectionString = sourceConnectionString ; } catch ( ArgumentException ) { return sourceConnectionString ; } object marsValue ; if ( ! configFileConnectionBuilder . TryGetValue ( XmlAttrNameMultipleActiveResultSets , out marsValue ) ) { configFileConnectionBuilder [ XmlAttrNameMultipleActiveResultSets ] = true . ToString ( ) ; } if ( ! configFileConnectionBuilder . ContainsKey ( ProviderConnectionStringPropertyNameApp ) && ! configFileConnectionBuilder . ContainsKey ( ProviderConnectionStringPropertyNameApplicationName ) ) { configFileConnectionBuilder [ ProviderConnectionStringPropertyNameApp ] = " " ; } return configFileConnectionBuilder . ConnectionString ; }
Injects the MARS/AppFramework attributes into the provider connection string
without pinging the connection to see if the database supports SQL 90 or newer.
Injects the MARS / AppFramework attributes into the provider connection string without pinging the connection to see if the database supports SQL 90 or newer .
// if the provider connection string's provider property is "System.Data.SqlClient" then add the  // MARS attribute (value is true if SQL Server version >= 9, false otherwise). Also add the App // attribute (with fixed value EntityFramework) - which is useful for statistics on server. // add MARS property if it does not already exist // add App attribute if neither App nor Application Name property is already set // note: fixed value so no localization;
sourceConnectionString
string
providerInvariantName
string