ASP.Net Configuration File & # 8594; Connection strings for multiple developers and deployment servers

I have a team of three developers, two of whom use a standard local test database, one of which uses its own database, as well as a server environment with a production database and a test database.

This means that multiple connection strings are required.

The web.config file is periodically updated and continues to be changed by each developer when performing version control updates, as well as the fact that sometimes the developer accidentally checks the connection string in his personal web.config file, which temporarily interrupts us after starting a subsequent update from the original element management.

What can I change so that the web.config file can be fixed / updated as often as necessary and not lead to breaking connection lines for other developers or require changes before it can be loaded into a test or production environment?

+6
web-config connection-string
source share
3 answers

You might want to take a look at replacing the ConnectionStrings section in Web.Config with the original Config file, transfer the LIVE set of connection strings to the original control, but not include them in the actual solution.

Information on using the configSource attribute can be found in the "Using External Configuration Files" section of the document:

Connection strings and configuration files

This has the advantage that developers can have their own settings that do not fall into the main Web.Config. The potential downside is that this is another file you need to worry about, and depending on how you get the latest version from the source code, may not help (for example, if you go to your SC client and say "Get the latest "that will overwrite the file, whereas if you are in Visual Studio, right-click on the solution / project and select" Get Last ", which will receive files only in projects).

+2
source share

For test and production conditions, you can use Visual Studio Web Deployment Projects . In this case, you can define the sections in the web.config file that will be replaced when creating the deployment package for the test / prod server.

0
source share

You can use the Enterprise Library data access unit to process database connections. Then you can define as many connection strings as you want, and simply change the usage key to any of them. See http://www.devx.com/dotnet/Article/30910 for details.

0
source share

All Articles