<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Untie LINQ to SQL Connection String from Application Settings</title>
	<atom:link href="http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/feed/" rel="self" type="application/rss+xml" />
	<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/</link>
	<description>Graham O&#039;Neale – Deep In .NET Development: ASP.NET, MVC, jQuery, WPF, WCF, Silverlight</description>
	<lastBuildDate>Wed, 28 Sep 2011 23:00:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Jeremy Bunga</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-39725</link>
		<dc:creator>Jeremy Bunga</dc:creator>
		<pubDate>Mon, 12 Sep 2011 16:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-39725</guid>
		<description>Many thanks!

This was very helpful and saved a lot of headaches. Thanks!</description>
		<content:encoded><![CDATA[<p>Many thanks!</p>
<p>This was very helpful and saved a lot of headaches. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mariano Barroumeres</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-37229</link>
		<dc:creator>Mariano Barroumeres</dc:creator>
		<pubDate>Mon, 22 Aug 2011 03:11:36 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-37229</guid>
		<description>I&#039;m not a LINQ to SQL pro, but why don&#039;t you just use the DataContext constructor which takes the connection string as a parameter? It&#039;s already auto generated by the designer in the Whatever.designer.cs

public WhateverDataContext(string connection) : 
		base(connection, mappingSource)
{
	OnCreated();
}

I mean, OK, you&#039;ll probably forget to delete the &#039;plain&#039; CS for your developing machine from time to time if sth has changed in your designer, but if you just need to use dynamic database credentials use the constructor provided for that. 
There are 5 constructors for the DataContext, there has to be one that fits your needs. 
Kind regards, Mariano.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not a LINQ to SQL pro, but why don&#8217;t you just use the DataContext constructor which takes the connection string as a parameter? It&#8217;s already auto generated by the designer in the Whatever.designer.cs</p>
<p>public WhateverDataContext(string connection) :<br />
		base(connection, mappingSource)<br />
{<br />
	OnCreated();<br />
}</p>
<p>I mean, OK, you&#8217;ll probably forget to delete the &#8216;plain&#8217; CS for your developing machine from time to time if sth has changed in your designer, but if you just need to use dynamic database credentials use the constructor provided for that.<br />
There are 5 constructors for the DataContext, there has to be one that fits your needs.<br />
Kind regards, Mariano.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-36097</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 09 Aug 2011 16:18:07 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-36097</guid>
		<description>Over the past 3 days I&#039;ve had a slew of issues deploying an MVC project to IIS because I naively expected the Linq to SQL class builder to play nice.  I changed my web.config and app.config, but kept getting a cryptic &quot;can&#039;t connect to database&quot; error.  After 2+ days of fruitless Googling, I finally discovered that my local connection string (using my local machine name) was hard-coded into the SQL classes.  No wonder the production server couldn&#039;t establish a connection!

I fixed all of the hard-coded references, but doing a massive search/replace every time I built was a pain.  Your solution is far more elegant.  Now I just need to manage my application&#039;s web.config and my DAL&#039;s app.config, both of which can be handled with XDT transformations tied to my build process.

Thank you for putting together an excellent resource!</description>
		<content:encoded><![CDATA[<p>Over the past 3 days I&#8217;ve had a slew of issues deploying an MVC project to IIS because I naively expected the Linq to SQL class builder to play nice.  I changed my web.config and app.config, but kept getting a cryptic &#8220;can&#8217;t connect to database&#8221; error.  After 2+ days of fruitless Googling, I finally discovered that my local connection string (using my local machine name) was hard-coded into the SQL classes.  No wonder the production server couldn&#8217;t establish a connection!</p>
<p>I fixed all of the hard-coded references, but doing a massive search/replace every time I built was a pain.  Your solution is far more elegant.  Now I just need to manage my application&#8217;s web.config and my DAL&#8217;s app.config, both of which can be handled with XDT transformations tied to my build process.</p>
<p>Thank you for putting together an excellent resource!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harshil Shukla</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-32940</link>
		<dc:creator>Harshil Shukla</dc:creator>
		<pubDate>Thu, 30 Jun 2011 09:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-32940</guid>
		<description>Hi,
Thanks a lot for this solution!!!
I have made my site working properly.
I have used only two steps of your solution and it is working fine now.
 :grin:  ;-)  :cool:</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Thanks a lot for this solution!!!<br />
I have made my site working properly.<br />
I have used only two steps of your solution and it is working fine now.<br />
 <img src='http://goneale.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':grin:' class='wp-smiley' />   <img src='http://goneale.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   <img src='http://goneale.com/wp-includes/images/smilies/icon_cool.gif' alt=':cool:' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Clausen</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-25720</link>
		<dc:creator>Aaron Clausen</dc:creator>
		<pubDate>Wed, 16 Mar 2011 04:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-25720</guid>
		<description>Jon&#039;s solution is the best.

I have been using the solution at the top of this blog article for many months, but it became quite dangerous in a production environment, because occasionally I would rebuild and deploy the project without remembering to change the designer.cs file. Then suddenly production is down because it can&#039;t find the database.

With Jon&#039;s solution, the partial class remains totally intact permanently, even after you make any desired edits to the DBML designer. No problem, because the partial class is in a separate file and stays there regardless.

The trick is &quot;removing all the connection gook&quot; which eliminates the &quot;member already declared problem&quot;.

Thanks Graham for raising an important topic with a solid solution and Jon for putting the icing on the cake.

Now I have zero issues with this and can deploy to production any time fear free, my connection strings just *work* ! :P</description>
		<content:encoded><![CDATA[<p>Jon&#8217;s solution is the best.</p>
<p>I have been using the solution at the top of this blog article for many months, but it became quite dangerous in a production environment, because occasionally I would rebuild and deploy the project without remembering to change the designer.cs file. Then suddenly production is down because it can&#8217;t find the database.</p>
<p>With Jon&#8217;s solution, the partial class remains totally intact permanently, even after you make any desired edits to the DBML designer. No problem, because the partial class is in a separate file and stays there regardless.</p>
<p>The trick is &#8220;removing all the connection gook&#8221; which eliminates the &#8220;member already declared problem&#8221;.</p>
<p>Thanks Graham for raising an important topic with a solid solution and Jon for putting the icing on the cake.</p>
<p>Now I have zero issues with this and can deploy to production any time fear free, my connection strings just *work* ! <img src='http://goneale.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PdeBie</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-25323</link>
		<dc:creator>PdeBie</dc:creator>
		<pubDate>Fri, 11 Mar 2011 16:38:33 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-25323</guid>
		<description>Thank you for this solution. I had exactly the same problem with my 3-tier application.

On my local computer everything worked fine, but when I changed the connectionString on the test server it couldn&#039;t make the connection (because test server was in different network).

Thanks again! I&#039;ve saved this page to my favorites.</description>
		<content:encoded><![CDATA[<p>Thank you for this solution. I had exactly the same problem with my 3-tier application.</p>
<p>On my local computer everything worked fine, but when I changed the connectionString on the test server it couldn&#8217;t make the connection (because test server was in different network).</p>
<p>Thanks again! I&#8217;ve saved this page to my favorites.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-23039</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Tue, 08 Feb 2011 20:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-23039</guid>
		<description>I am using this but sqlMetal stomps it.  Anybody know where \ what file &quot;Application Settings = Flase&quot; is kept in?</description>
		<content:encoded><![CDATA[<p>I am using this but sqlMetal stomps it.  Anybody know where \ what file &#8220;Application Settings = Flase&#8221; is kept in?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don Wilcox</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-20033</link>
		<dc:creator>Don Wilcox</dc:creator>
		<pubDate>Tue, 11 Jan 2011 16:30:12 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-20033</guid>
		<description>Thanks for the original post and follow-ups. I was able to get it to work using the partial class method, with one additional step: every time I add a table to the designer, I have to go in and remove the static connection string from the DataContext properties window. A bit of a pain, but not a horrible one, especially given the benefits of having the connection string out of my data layer. :smile:</description>
		<content:encoded><![CDATA[<p>Thanks for the original post and follow-ups. I was able to get it to work using the partial class method, with one additional step: every time I add a table to the designer, I have to go in and remove the static connection string from the DataContext properties window. A bit of a pain, but not a horrible one, especially given the benefits of having the connection string out of my data layer. <img src='http://goneale.com/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fu</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-15475</link>
		<dc:creator>Fu</dc:creator>
		<pubDate>Thu, 18 Nov 2010 16:26:53 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-15475</guid>
		<description>Great step by step, my friend..! Just as what I need. Really helpful
 ;-)</description>
		<content:encoded><![CDATA[<p>Great step by step, my friend..! Just as what I need. Really helpful<br />
 <img src='http://goneale.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: richard henwood</title>
		<link>http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/comment-page-1/#comment-13541</link>
		<dc:creator>richard henwood</dc:creator>
		<pubDate>Wed, 06 Oct 2010 12:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://goneale.wordpress.com/?p=552#comment-13541</guid>
		<description>why not just comment out the constructor for the DBML that has no connection string argument,
 i.e.

Public Sub New()
 MyBase.New(......)
 OnCreated
End Sub

since it is the one that uses application settings and the other constructors use the connection string. instead of complicating your life.

Ritchieh.sd</description>
		<content:encoded><![CDATA[<p>why not just comment out the constructor for the DBML that has no connection string argument,<br />
 i.e.</p>
<p>Public Sub New()<br />
 MyBase.New(&#8230;&#8230;)<br />
 OnCreated<br />
End Sub</p>
<p>since it is the one that uses application settings and the other constructors use the connection string. instead of complicating your life.</p>
<p>Ritchieh.sd</p>
]]></content:encoded>
	</item>
</channel>
</rss>

