Or alternatively should ConnectionStrings.config just be left up to the server environment and never part of your VS publish?


I would like you to add connection string in VS, there are a few advantages:

  1. You can manage connection string of multiple environments like UAT, Prod, Debug, Release
  2. If you want to add some custom connection string then you can also add in that and it will also get published
  3. You can transform connection string using SlowCheetah

After the SlowCheetah installation, you need to click Add Transform which will transform connection string config according to your build configuration like Debug, Release, UAT, Prod, etc..

You can create ConnectionStrings.Debug.config.example file, which will be like below

<?xml version="1.0"?>
  <add name="core" connectionString="#{ConnectionString.Core}" />
  <add name="master" connectionString="#{ConnectionString.Master}" />
  <add name="web" connectionString="#{ConnectionString.Web}" />

So every time when new developer will take code, then they can create own ConnectionStrings.Debug.config file according to buid configuration and place there connections like below:

 <?xml version="1.0"?>
<connectionStrings xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <add name="core"
       xdt:Transform="Replace" xdt:Locator="Match(name)" />
  <add name="master"
       xdt:Transform="Replace" xdt:Locator="Match(name)" />
  <add name="web"
       xdt:Transform="Replace" xdt:Locator="Match(name)" />  
  • Makes sense to me... and I like the idea of the config transforms on ConnectionStrings.config much like you'd do with any other App.config or Web.config Oct 24 '19 at 14:48
  • ConnectionStrings get set when you install Sitecore. Where is the benefit of having them in source control?
    – Richard Seal
    Nov 14 '19 at 0:33

Ideally It should not be a part of your VS Publish, it should be left as it is in server. As you have connectionstring.config related to environments not code.

But if you have any custom database used in solution and varies according to environment then you may want to manage it form VS source control then you need to use transform tool like SlowCheetah which will create transform file according to your environment and it has to be configured as per all environment with value specific to respective environment by you.

If you go the link link will provide all information to you for how transform works.

Hope this will help.


I would recommend that you use deploy time replacement to control connection strings. Have a look at how Octopus Deploy does this: https://octopus.com/docs/deployment-process/variables/variable-substitutions

I then have development connection strings checked into source control and use config transforms to add in the token for replacement at deploy time. It's best practice not to include sensitive information in source control, and connection strings fall into this category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.