title: "Cleanly" Deploying an ASP.NET Application with LINQ to SQL Server
body: <p>In my development environment, my SQL Server is <code>PHILIP\SQLEXPRESS</code>. In testing, it's <code>ANNIE</code>, and the live environment will have a third name yet to be determined. I would have assumed that updating the following statement in <code>web.config</code> would have been enough:</p>
  
  <pre><code>&lt;add name="MyConnectionString"providerName="System.Data.SqlClient" 
  connectionString="Data Source=PHILIP\SQLEXPRESS;Initial Catalog=MyDtabase;Integrated Security=True" /&gt;
  </code></pre>
  
  <p>When using <code>SqlConnection</code>, <code>SqlCommand</code>, <code>SqlDataReader</code> and friends, that's all it took. Using LINQ, it doesn't seem to work that nicely. I see the servername repeated in my <code>.dbml</code> file as well as in <code>Settings.settings</code>. After changing it in all of those places, I get it to work. However if I'm doing a few deployments per day during testing, I want to avoid this regimen.</p>
  
  <p>My question is: is there a programmatic solution for LINQ to SQL that will allow me to specify the connection string once, preferably in <code>web.config</code>, and get everybody else to refer to it?</p>
  
  <p>-- EDIT --</p>
  
  <p>The following connection statement is in my .dbml file:</p>
  
  <pre><code>&lt;Connection Mode="AppSettings" ConnectionString="Data Source=PHILIP\SQLEXPRESS;
  InitialCatalog=MyDatabase;Integrated Security=True" 
  SettingsObjectName="MyDatabase_Data_Access_Layer.Properties.Settings" 
  SettingsPropertyName="MyConnectionString" Provider="System.Data.SqlClient" /&gt;
  </code></pre>