<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Captain Codeman&#187; alias</title>
	<atom:link href="http://www.captaincodeman.com/tag/alias/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.captaincodeman.com</link>
	<description>Software Developer</description>
	<lastBuildDate>Fri, 15 Jul 2011 22:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Use Aliases to develop against SQL Server on different machines</title>
		<link>http://www.captaincodeman.com/2008/03/13/use-aliases-to-develop-against-sql-server-on-different-machines/</link>
		<comments>http://www.captaincodeman.com/2008/03/13/use-aliases-to-develop-against-sql-server-on-different-machines/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 20:11:00 +0000</pubDate>
		<dc:creator>Captain Codeman</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blogs.intesoft.net/post.aspx?id=c8919fca-240c-4855-a6d5-a9212cfb16d6</guid>
		<description><![CDATA[This is a little tip that I&#39;ve found useful when working on projects on different machines. If you have a desktop machine and separate database server then you generally wouldn&#39;t need to have SQL server running locally &#8211; either the full version OR the SQL Express edition. So, within your app the connection string would


No related posts.]]></description>
			<content:encoded><![CDATA[<p>
This is a little tip that I&#39;ve found useful when working on projects on different machines.
</p>
<p>
If you have a desktop machine and separate database server then you generally wouldn&#39;t need to have SQL server running locally &#8211; either the full version OR the SQL Express edition.
</p>
<p>
So, within your app the connection string would reference the name of the server, e.g.:
</p>
<p><div class="code"><span class="kwrd">&lt;</span><span class="html">connectionStrings</span><span class="kwrd">&gt;</span></p>
<p>  <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&#8221;Library&#8221;</span> <span class="attr">connectionString</span><span class="kwrd">=&#8221;Data Source=MyServer;Initial Catalog=Library;Integrated Security=False;User ID=library;Password=secret;&#8221;</span> <span class="attr">providerName</span><span class="kwrd">=&#8221;System.Data.SqlClient&#8221;</span><span class="kwrd">/&gt;</span></p>
<p> <span class="kwrd">&lt;/</span><span class="html">connectionStrings</span><span class="kwrd">&gt;</span></div>
</p>
<p>
&nbsp;
</p>
<p>
The problem is of course when you checkout this code on another machine such as a laptop when working on-the-road&nbsp;(or just down in the basement while watching&nbsp;an episode of &#39;Lost&#39; <img src="/admin/tiny_mce/plugins/emotions/images/smiley-smile.gif" border="0" alt="Smile" title="Smile" width="18" height="18" />)
</p>
<p>
Sure, you can just change the config to say &#39;(local)&#39; or &#39;(local)\SQL2005&#39; or whatever &#8230; but you run into issues with the file being changed and then having to change it back if you check it in.
</p>
<p>
Urgh.
</p>
<p>
The simplest solution I&#39;ve found is to setup an Alias using the SQL Server Configuration Manager:
</p>
<ul>
<li>
<div>
	On the desktop machine, setup an alias called &#39;dbserver&#39; pointing to the proper database server.
	</div>
</li>
<li>
<div>
	On the laptop machine, setup&nbsp;the same alias called &#39;dbserver&#39; this time pointing to the local instance.
	</div>
</li>
</ul>
<p>
Now, the same connection string can be run on both machines (using &#39;Data Source=dbserver&#39; in the connection string) without having to worry about changing it when checking it out and&nbsp;not checking it in if you changed it.
</p>
<p>
NOTE: I usually generate the database schema from the C# classes and NHibernate mapping file and include a data-setup tool so it isn&#39;t an issue having two separate databases and normally most of the work is on the actual application and not so much on the database schema.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.captaincodeman.com/2008/03/13/use-aliases-to-develop-against-sql-server-on-different-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

