How to vary connection string for different work locations

后端 未结 7 2033
情话喂你
情话喂你 2021-02-10 15:55

I am working on a C# 4.0, WPF 4.0, SQL 2008 project and I do work at home and in the office. I just setup SubVersion using Visual SVN per the recommendations found in other ques

7条回答
  •  长发绾君心
    2021-02-10 16:11

    .NET has a way of overriding settings in one config file from those in another using the file attribute. We usually do something like this:

    web.config

    
        
            
        
    
    

    web.custom.config

    
        
    
    

    By convention, we set up our source control system [SVN] to ignore any custom.config files. This allows us to check-in the core, default settings while still allowing each developer to manage environment-specific settings.

    Note: this only works with the key. If you're storing connection strings in the key, consider moving those settings to appSettings instead.

    See http://msdn.microsoft.com/en-us/library/ms228154.aspx

提交回复
热议问题