Share via


How to: Update Database Connection Strings in Configuration Files

When you prepare to deploy database consumer applications, you need to update their configuration files with the database connection strings used in the deployment environment. For more information, see Overview of Deployment Using Deployment Reports.

To update the deployment database connection string for an ASP.NET, Windows, or Office application

  1. Open the application configuration file for the application connected to the database provider endpoint.

    Note

    This file is a Web.config file for an ASP.NET application or an App.config file for a Windows or Office application.

  2. In the application configuration file, locate the <connectionStrings> element.

  3. Under the <connectionStrings> element, locate the <add> element whose "ConnectionString" attribute matches the value in the Connection String property of the database consumer endpoint.

    Tip

    You can find the Connection String property by selecting the database consumer endpoint on the application diagram and pressing F4 to open the Properties window.

  4. From the <add> element, copy the value of the "Name" attribute to the Config File Entry setting on the database consumer endpoint.

    Tip

    To locate the Config File Entry setting, right-click the database consumer endpoint on the application diagram and choose Settings and Constraints. In the Settings and Constraints Editor, select the Application Endpoint Settings node. The Config File Entry setting is located in the right pane of the Settings and Constraints Editor. For more information, see Settings and Constraints Editor.

  5. If you have not already obtained the database connection string used for deployment, obtain that connection string.

  6. In the <add> element, replace the value in the "ConnectionString" attribute with the database connection string used for deployment.

    Tip

    If needed, use the value that you copied to the Config File Entry setting to locate the <add> element with a matching "Name" attribute value in the Web.config file.

Copying the "Name" attribute value to the Config File Entry setting specifies the configuration file entry that maps to the consumer endpoint. At deployment, this setting determines which configuration file entry to set once deployment parameters are resolved. You can also use this setting to locate that value in the application configuration file when you update the database connection string.

Security

By default, database connection strings and certain other settings are written unencrypted and as plain text to consumer application configuration files. For more information, see How to: Configure Connections to External Databases and Considerations for Implementing Applications.

See Also

Other Resources

Preparing to Deploy Distributed Systems