Web.config Versions

I am currently using a common database model for our development. I know that it is better to use local development databases to properly manage database versions without one developer violating all other codes. So I'm trying to get there. However, I have a question about the web.config file. How can I guarantee that every time each developer has his own local development database, he does not need to manually change the database connection string every time he receives an update from the control source? What is the best way to do this?

For example, let's say Johnny Dev takes his web.config file, which contains a connection string, such as:

server=JohnnysBox;database=JohnnyAppDev1; 

So, now Susie Dev is getting the update, and she should change her connection string to this:

 server=SUE;database=development; 

So, now Susie and Johnny continue to write their own connection strings to the web.config file, and every time they get an update, they have to change the connection strings in all applications.

What is the best way to cope with this situation so that developers do not mess up the settings of the connection string to each other, but may require other changes to the configuration files for all other developers when necessary (for example, a new application configuration)?

+4
source share
8 answers

For configuration files or settings, you need the version:

  • template files ( server=@USER _NAME@ ; database=@DATABASE _NAME@ ; )
  • one or more value files
  • one script able to replace variables with the correct values
+2
source

This is only a partial solution, but you could force all developers to create an alias for their own SQL server using cliconfg.

Then web.config in the original control will have, for example:

 server=LocalServerAlias;database=development 
+3
source

What we do is never pass the web.config file to the original control. Instead, we commit the web.config.sample file, and each developer combines the changes in this file into their own web.config file. Each developer is responsible for these mergers.

+1
source

The way I do this is simply not to check the changes made by the developer to the configuration files.

When you need to change a configuration change, I start with a β€œclean” configuration file and make the necessary changes, and then go in. When everyone else gets the latest version, they can merge these changes into their local versions.

+1
source

The solution we came up with in my office was that we specifically excluded web.config from version control, but only to the www folder. This allows developers to make any changes that they need locally.

In a separate folder we have a "main" copy of the web.config file, with which the version is controlled . As you add new sections, keys, etc. Responsibility of the developer for updating the master copy.

+1
source

You can create multiple Web.config files depending on the environment in which the application runs. Using the conversion syntax, you can modify the main Web.config file to enable or perform your own local settings.

http://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx

Then exclude this custom Web.xxx.config from your repository.

+1
source

We run web.config. So, I have one called Mattweb.config, and I can change it as I like, and it replaces web.config ON MY LOCAL MACHINE ONLY with the contents of Mattweb.config. This does not require intervention with me.

We also share the β€œreal” web.config so that I can compare with my own local version to see if any add-ons or any other changes have been added. Then I just update the Mattweb.config file and everything is fine again.

+1
source

Use (locally) as the sql server name and always refer to the local server. This should be the default value in the web.config file that you check in the source control.

To install β€œinstall”, your installer must ask the user if he wants to use the remote sql server, and if so, update the web.config files as part of the installation process.

0
source

All Articles