Storing EF database connection strings in Silverlight project
We're a team of 4 developers working on the same project. We use Entity Framework to access our SQL database backend. We store the connection string in web.config.
Each developer is testing his code towards his own local SQL server database. T开发者_开发百科his means that each developer has his own SQL Server connection string in web.config. I typically have several different copies of the database on my machine, with data from different scenarios, which I switch between by editing the connection string. One database may be empty, another may contain huge amounts of test data and so on.
The problem we're facing is that we accidentally check in the web.config into source control regulary, which means that when one of the other developers on a team retrieves latest code from source control, his local web.config - with his connection string - will be overwritten with the one from the other developer. (We're using AccuRev by the way, in which there's no good way to ignore certain files).
I've thought of a couple of different hackish solutions:
- Create a new configuration file, where we store computer-specific configurations. We don't check in this file in source control. Or we check it in using some other name.
- Rename web.config to web.config.default (or something) in source control. After a checkout from source control, the developer has to rename web.config.default to web.config before he can run.
Surely there must be som standard way of handling this?
if you use visual studio 2010, you can use the web.config transformation.
just a thought...
every developer need to set up his/her own build-configuration, like DebugDeveloperA, DebugDeveloperB, Staging, Relase, etc...
Visual Studio 2010 creates web.config tranformation files for every build configuration, so if you get the latest version from source control, you need to make sure, that you use your build configuration.
I went with the following solution:
- Rename web.config to web.config.default (or something) in source control.
- As a prebuild step, check if the web.config exists. If not, copy web.config.default to web.config.
精彩评论