I've tried several approaches with *.gitignore
for managing connection strings when working on a larger team.
From the official repository of .gitignore
files at gitignore, I've downloaded VisualStudio.gitignore and used it as a starting point for all the projects.
The same process can be done by visiting http://gitignore.io/, typing VisualStudio, then downloading the file.
The approach I currently use is by leveraging the SectionInformation.ConfigSource Property
<connectionStrings configSource="myConnectionStrings.config" />
and then adding myConnectionStrings.config to .gitignore
, which is nice because it doesn't add the entire *.config
.
Also you can use the same myConnectionStrings.config inside another project (your MyProject.Data layer)
<configuration>
<connectionStrings configSource="myConnectionStrings.config"/>
</configuration>
Just remember to set Copy always!
Also I've tried using filters as described at Git - Ignoring a specific modification to a config file, but I find that to be an overkill.
I wonder if there is any other approach that is considered a best practice?