I’m part of a small development team and we are currently moving from a model where we share the same development database to a model where we all have our own personal development databases..
Because of this, we are trying to figure out how to manage the web and app .config files to accommodate the individual databases. Clearly we want to avoid the situation where everyone will need to manually change the connection string to point to their own database then remember to change it back before checking back in!
I’m sure this is a very common problem that faces almost all development teams. Despite this, I cannot find any solutions to this problem.
I am familiar with web.config transformations using xdt syntax and while this helps with the modification of the files, it doesn’t (as far as I know) provide a way to inject in an external parameter value. For example, we would need the transformation to detect the current user, and replace the database name in the .config with one containing their username.
So, how to you solve this problem in your development team?
Thanks.
Edit:
Sorry, I missed a fairly important piece of information that prevents these answers from being acceptable. As a company, we all work remotely and remote desktop into our development environment. We effectively have one (powerful) development machine that all developers rdp into and use simultaneously. Therefore, using aliases or modifying host files etc would apply to all users equally and not provide the individual customization necessary. The SQL instance is already a local instance, it is just a local instance on the machine that is used by all developers.
I can suggest two ways of doing this.
Use the same alias for your database server name so that connection strings will be identical, you can do this by putting the following line into your hosts file:
127.0.0.1 DBSERVER
Put your connection strings into external file and don’t add it to the source control. For the staging and release configurations you can add required connection strings through web config transformations.
In the second case your web.config will look like this:
EDIT:
Where
connectionStrings.configfile is placed in the same folder but is added to ignore list under source control so that each developer will have his own copy of this file and his changes will not affect other developers. To simplify things you can create aconnectionStrings.config.defaultfile that can be used as a template so that when new developer joins the project he will create his own copy ofconnectionStrings.configbased on this file with default values.