title: Add connectionstring to web.config if not already set
body: <p>I'm looking for a way to add a connectionString to my web.config file only when a connectionString with that name does not already exist.</p>
  
  <p>For example:</p>
  
  <p>I have this set in my current web.config file</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="myDB" providerName="System.Data.SqlClient" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=myDB;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>In the IIS settings on the production server I also added the connectionString for "myDB" so that I don't have the production connectionString in the sources.
  <a href="http://i.stack.imgur.com/rumdK.png" rel="nofollow">[Image of the IIS settings]</a></p>
  
  <p>If I am now going to Deloy my WebApp to the IIS I get the message that there already is an entry with the name "myDB".</p>
  
  <p>Is there a way to only use the connectionString from the web.config file when there is not already one set in the IIS server settings?</p>