How to remove a ConnectionString using Config Transformations

This will remove a specific connection string based on its name.

<configuration>
  <connectionStrings> 
    <add name="ConnStr2" xdt:Transform="Remove" xdt:Locator="Match(name)" connectionString=" " /> 
  </connectionStrings> 
</configuration>

Note that the connectionString value is not empty string, but is instead a space. Any non-empty value would do.

Leave a Comment