/// <summary> /// Update the web.config connection strings. If the EntityFramework is being used, two connection strings /// will be created. One for the EntityFramework, and another for the Membership system. /// </summary> /// <param name="config"></param> /// <param name="configSection"></param> private void UpdateConnectionString(InstallerConfig config, Configuration configSection) { ConnectionStringsSection connectionStringsSection = configSection.ConnectionStrings; string connString = string.Empty; string providerName = string.Empty; if (!string.IsNullOrEmpty(config.Database.EntityFrameworkEntitiesName)) { // EntityFramework connection string providerName = component.GetProviderName; connString = component.GetConnString(); string efname = config.Database.EntityFrameworkEntitiesName; ConnectionStringSettings appTemplate = new ConnectionStringSettings(config.Database.EntityFrameworkEntitiesName, connString, providerName); //connectionStringsSection.ConnectionStrings.Clear(); connectionStringsSection.ConnectionStrings.Add(appTemplate); if (!string.IsNullOrEmpty(config.Database.EntityFrameworkEntitiesName) && config.Membership.Create) { config.Database.EntityFrameworkEntitiesName = ""; ConnectionStringSettings connTemplate = new ConnectionStringSettings("MembershipConnection", component.GetConnString(), "System.Data.SqlClient"); connectionStringsSection.ConnectionStrings.Add(connTemplate); config.Database.EntityFrameworkEntitiesName = efname; } } else { // Standard SqlServer Connection string providerName = component.GetProviderName; connString = component.GetConnString(); ConnectionStringSettings appTemplate = new ConnectionStringSettings(config.Database.ConnectionStringName, connString, providerName); //connectionStringsSection.ConnectionStrings.Clear(); connectionStringsSection.ConnectionStrings.Add(appTemplate); } }
/// <summary> /// Update the web.config connection strings. If the EntityFramework is being used, two connection strings /// will be created. One for the EntityFramework, and another for the Membership system. /// </summary> /// <param name="config"></param> /// <param name="configSection"></param> private void UpdateConnectionString(InstallerConfig config, Configuration configSection) { string connString = component.GetConnString(); string providerName = "System.Data.SqlClient"; if (!string.IsNullOrEmpty(config.Database.EntityFrameworkEntitiesName)) { providerName = "System.Data.EntityClient"; connString = component.BuildEntityFrameworkConnectionString(); } ConnectionStringsSection connectionStringsSection = configSection.ConnectionStrings; ConnectionStringSettings appTemplate = new ConnectionStringSettings(config.Database.ConnectionStringName, connString, providerName); connectionStringsSection.ConnectionStrings.Clear(); connectionStringsSection.ConnectionStrings.Add(appTemplate); if (!string.IsNullOrEmpty(config.Database.EntityFrameworkEntitiesName) && config.Membership.Create) { ConnectionStringSettings connTemplate = new ConnectionStringSettings("MembershipConnection", component.GetConnString(), "System.Data.SqlClient"); connectionStringsSection.ConnectionStrings.Add(connTemplate); } }