<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>CinVin</title>
		<link>http://www.cinvin.com/forums/</link>
		<description>vBulletin styles, vBulletin skins, vBulletin templates, buttons, and smilies  -- Quality at affordable prices!</description>
		<language>en</language>
		<lastBuildDate>Thu, 02 Sep 2010 13:39:01 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.cinvin.com/forums/images/misc/rss.jpg</url>
			<title>CinVin</title>
			<link>http://www.cinvin.com/forums/</link>
		</image>
		<item>
			<title>August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=104558&amp;goto=newpost</link>
			<pubDate>Mon, 30 Aug 2010 08:37:57 GMT</pubDate>
			<description><![CDATA[*August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   Here is the latest in my link-listing series (http://weblogs.asp.net/scottgu/archive/2010/07/09/july-9th-links-asp-net-asp-net-mvc-jquery-silverlight-wpf-vs-2010.aspx).*...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   Here is the latest in my <a href="http://weblogs.asp.net/scottgu/archive/2010/07/09/july-9th-links-asp-net-asp-net-mvc-jquery-silverlight-wpf-vs-2010.aspx" target="_blank">link-listing series</a>.* Also check out my <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx" target="_blank">VS 2010 and .NET 4 series</a> and <a href="http://weblogs.asp.net/scottgu/archive/2010/01/10/asp-net-mvc-2.aspx" target="_blank">ASP.NET MVC 2 series</a> for other on-going blog series I’m working on.<br />
<br />
    <i>[In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: <a href="http://twitter.com/scottgu" target="_blank">twitter.com/scottgu</a>]</i><br />
<br />
    <b><u>.NET/WPF/EF</u></b><br />
<br />
    <ul><li>       <a href="http://geekswithblogs.net/BlackRabbitCoder/archive/2010/08/26/c.net-five-little-wonders-that-make-code-better-1-of.aspx" target="_blank">5 Little C#/.NET Wonders that Make Code Better</a>: Nice blog post from James that highlights 5 nice language/framework tips you can take advantage of within your apps.* I’m betting a lot of people didn’t know about the StopWatch class.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://10rem.net/blog/2010/08/02/announcing-microsoft-ribbon-for-wpf-rtw" target="_blank">WPF Ribbon Control Released</a>: The WPF team recently released the final V1 release of the WPF Ribbon control.* This makes it easy to build ribbon-based applications. Also read this <a href="http://blogs.msdn.com/b/wpf/archive/2010/08/03/introducing-microsoft-ribbon-for-wpf.aspx" target="_blank">WPF team blog post</a> for lots of great details on what it enables.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://romiller.com/2010/07/14/ef-ctp4-tips-tricks-include-with-lambda/" target="_blank">EF4 .Include() Method w/ Lambda Support</a>: Ever wanted to use a Lambda expression instead of a string parameter when eagerly loading associations in EF4 using the Include() method?* This blog post shows you how you can.<br />
<br />
   </li>
</ul>    <b><u>ASP.NET</u></b><br />
<br />
    <ul><li>       <a href="http://madskristensen.net/post/Performance-tuning-tricks-for-ASPNET-and-IIS-7-part-1.aspx" target="_blank">Performance Tuning tricks for ASP.NET and IIS7 Part 1</a> and <a href="http://madskristensen.net/post/Performance-tuning-tricks-for-ASPNET-and-IIS-7-e28093-part-2.aspx" target="_blank">Part 2</a>: Mads has a nice set of posts that detail some great performance optimization tips you can use with ASP.NET and IIS7.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.4guysfromrolla.com/articles/071410-1.aspx" target="_blank">Better ViewState Management in ASP.NET 4 with the ViewStateMode Property</a>: Scott Mitchell has a good article that discusses the new ViewStateMode property supported on ASP.NET 4 controls. This provides much more control over how viewstate is used within a page.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.4guysfromrolla.com/articles/081110-1.aspx" target="_blank">Filtering Data using ASP.NET 4’s QueryExtender Control</a>: Scott Mitchell has a nice article that talks about the new  control in ASP.NET 4 that makes enabling dynamic querying against a LinqDataSource or EntityDataSource really easy.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.4guysfromrolla.com/articles/072810-1.aspx" target="_blank">Techniques to Avoid Duplicate URLs</a>: Scott Mitchell has another great article that discusses techniques you can use within ASP.NET to avoid exposing duplicate URLs to the same content within your web-sites.* These can help improve your search engine traffic.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://blogs.msdn.com/b/scothu/archive/2010/08/26/automatically-prepopulate-fields-for-insert-in-net-4.aspx" target="_blank">Automatically pre-populate fields for Insert in ASP.NET 4</a>: Scott Hunter has a nice blog post that discusses how to specify default values for insert with data controls in ASP.NET 4.<br />
<br />
   </li>
</ul>    <b><u>ASP.NET MVC</u></b><br />
<br />
    <ul><li>       <a href="http://mvccontribgallery.codeplex.com/" target="_blank">MvcContrib Template Gallery</a>: Download 58 pre-built ASP.NET MVC Template Gallery styles that you can use to customize the look and feel of your applications. All available under a Community Commons license.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://weblogs.asp.net/gunnarpeipman/archive/2010/07/04/stepping-into-asp-net-mvc-source-code-with-visual-studio-debugger.aspx" target="_blank">Step into the ASP.NET MVC Source Code with the VS Debugger</a>: Nice blog post by Gunnar that describes how to use VS 2010’s built-in symbol server support to enable you to step into the ASP.NET MVC Framework source code when debugging.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://weblogs.asp.net/jgalloway/archive/2010/07/13/server-installation-options-for-asp-net-mvc-2.aspx" target="_blank">Installation Options for ASP.NET MVC</a>: Jon has a good post that describes how to install ASP.NET MVC 2 on a server. There are a couple of options you can use for servers that don’t already have ASP.NET MVC installed – the easiest is to just enable the “Copy Local” flag on System.Web.Mvc.dll and install it in the \bin directory.<br />
<br />
   </li>
</ul>    <b><u>IIS Developer Express</u></b><br />
<br />
    <ul><li>       <a href="http://channel9.msdn.com/posts/Glucose/Hanselminutes-on-9-Razor-IIS-Express-SQL-4-Compact-Edition-and-VS2010-Tooling-with-Damien-Edwards/" target="_blank">Visual Studio Support for IIS Express, SQL 4 Compact Edition, and Razor syntax</a>: Channel 9 video with Damian Edwards and Scott Hanselman that discusses the support coming to enable IIS Express, SQL 4 CE, and Razor syntax support within Visual Studio 2010.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.intrepidstudios.com/blog/2010/7/11/debug-your-net-web-project-with-iis-express-t.aspx" target="_blank">How to Use IIS Express with VS today</a>: Kamran has a nice blog post that describes how you can use IIS Express with Visual Studio today – without having to wait for the official Visual Studio patch to enable it.<br />
<br />
   </li>
</ul>    <b><u>Silverlight and Windows Phone 7</u></b><br />
<br />
    <ul><li>       <a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/08/23/a-developer-s-roadmap-to-windows-phone-7-launch-timing.aspx" target="_blank">Developers Roadmap for Windows Phone 7</a>: The Windows Phone 7 team blogs about the release timeframe for Windows Phone 7 and the Visual Studio and Expression Blend tools for targeting it.* The official developer release will be on September 16th.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.msdev.com/Directory/SeriesDescription.aspx?CourseId=158" target="_blank">Windows Phone 7 in 7 Minutes</a>: Really nice set of 7 minute videos that enable you to quickly understand and learn Windows Phone 7 and the development fundamentals behind it.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://blogs.msdn.com/b/mikeormond/archive/2010/08/19/windows-phone-7-jumpstart-training-on-demand.aspx" target="_blank">Windows Phone 7 Jumpstart Training</a>: Nice list of free training sessions you can watch online to learn how to build Windows Phone 7 applications using Silverlight and XNA.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.jeff.wilcox.name/2010/08/looking-ahead-at-panorama-and-pivot/" target="_blank">Silverlight Panorama and Pivot Controls for Windows Phone 7</a>: Jeff has a great post that discusses the awesome new Panorama and Pivot controls for Silverlight that will be part of the final Windows Phone 7 developer release.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://blogs.msdn.com/b/mikeormond/archive/2010/08/27/xna-from-silverlight-on-windows-phone-7-the-microphone.aspx" target="_blank">Using XNA from Silverlight on Windows Phone 7</a>: Good blog post from Mike that demonstrates how to use XNA APIs from Silverlight applications on Windows Phone 7.* This post demonstrates how to use the XNA audio framework from Silverlight.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=3a8636bf-185f-449a-a0ce-83502b9ec0ec" target="_blank">Creating High Performance Silverlight Applications for Windows Phone 7</a>: This is a great whitepaper written by my team that discusses best practices for building Silverlight applications that run well on Windows Phone 7.<br />
<br />
   </li>
</ul>    <ul><li>       <a href="http://www.hanselman.com/blog/HanselminutesPodcast228PerformanceOfSilverlightOnWindowsPhone7.aspx" target="_blank">Performance of Silverlight on Windows Phone 7</a>: A nice podcast with Scott Hanselman that discusses tips and techniques to enable smooth applications and great experiences on Windows Phone 7.<br />
<br />
   </li>
</ul>    <b><u>Book Recommendation</u></b><br />
<br />
    People often ask me for .NET book recommendations. Below is one book I always keep close by and find super-useful.* If you are looking for a good one-volume C# and .NET Base Class Library reference, <a href="http://www.amazon.com/gp/product/0596800959?ie=UTF8&amp;tag=scoblo04-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596800959" target="_blank">C# 4.0 in a Nutshell</a> a great one:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/ir1_42589914.gif" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/ir1_thumb_5671B59D.gif" border="0" alt="" /></a><a href="http://www.amazon.com/gp/product/0596800959?ie=UTF8&amp;tag=scoblo04-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596800959" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/nutshell_79BEAA42.jpg" border="0" alt="" /></a> <br />
<br />
    Hope this helps,<br />
<br />
    Scott<br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7601960" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/29/august-29th-links-net-asp-net-iis-express-silverlight-windows-phone-7.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=104558</guid>
		</item>
		<item>
			<title>Patch for VS 2010 Find and Replace Dialog Growing</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=104559&amp;goto=newpost</link>
			<pubDate>Mon, 30 Aug 2010 08:37:57 GMT</pubDate>
			<description><![CDATA[*Patch for VS 2010 Find and Replace Dialog Growing* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   One of the top reported Microsoft Connect issues with VS 2010 has been an issue with the Find and Replace dialog – which grows 16px each time you use it (which is pretty annoying). 
 
    The...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">Patch for VS 2010 Find and Replace Dialog Growing</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   One of the top reported Microsoft Connect issues with VS 2010 has been an issue with the Find and Replace dialog – which grows 16px each time you use it (which is pretty annoying).<br />
<br />
    The Visual Studio team recently <a href="http://blogs.msdn.com/b/visualstudio/archive/2010/08/12/patch-available-for-the-growing-find-and-replace-dialog.aspx" target="_blank">released a patch</a> that fixes this issue. You can download and apply it <a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30518&amp;wa=wsignin1.0" target="_blank">here</a>.<br />
<br />
    Hope this helps,<br />
<br />
    Scott<br />
<br />
    P.S. A few people reported issues installing the patch if they had an older version of the Silverlight 4 tools installed.* If you see an error message that says you need an update to Visual Studio to support Silverlight 4, you can fix it by installing the latest <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=40ef0f31-cb95-426d-9ce0-00dcfabf3df5&amp;displaylang=en" target="_blank">Silverlight 4 tools release</a>.<br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7601935" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/29/patch-for-vs-2010-find-and-replace-dialog-growing.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=104559</guid>
		</item>
		<item>
			<title>Search and Navigation Tips/Tricks with Visual Studio</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=104311&amp;goto=newpost</link>
			<pubDate>Tue, 24 Aug 2010 15:16:41 GMT</pubDate>
			<description><![CDATA[*Search and Navigation Tips/Tricks with Visual Studio* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   This is the twenty-seventh in a series of blog posts (http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx) I’m doing on the VS 2010 and .NET 4 release. 
 
   ...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">Search and Navigation Tips/Tricks with Visual Studio</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   This is the twenty-seventh in a <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx" target="_blank">series of blog posts</a> I’m doing on the VS 2010 and .NET 4 release.<br />
<br />
    Today’s blog post continues on from the <a href="http://weblogs.asp.net/scottgu/archive/2010/08/18/debugging-tips-with-visual-studio-2010.aspx" target="_blank">Debugging Tips post</a> I did last week, and covers some useful searching and navigation tips/tricks you can take advantage of within Visual Studio.* These tips were ones that my friend <a href="http://scottcate.com/" target="_blank">Scott Cate</a> (who has blogged dozens of great VS tips and tricks <a href="http://scottcate.com/Tricks/" target="_blank">here</a>) recently recommended to me as good tips that most developers using Visual Studio don’t seem to know about (even though most have been in the product for awhile).* <br />
<br />
    Hopefully this post will help you discover them if you aren’t already taking advantage of them.* They are all easy to learn, and can help save you a bunch of time.<br />
<br />
    <b><u>Ctrl + i - Incremental Search</u></b><br />
<br />
    Most developers using Visual Studio are familiar with the “Find dialog” that you can launch by pressing the “Ctrl + F” key within the IDE.* A surprisingly large number of developers, though, aren’t familiar with the “Incremental Search” capability within Visual Studio. This enables you to search within your current document, and enables you to do so without having to bring up a dialog.* <br />
<br />
    <u>Using Incremental Search</u><br />
<br />
    To enable incremental search, just type “Ctrl + i” within the editor.* This will subtly change your cursor, and cause your status bar at the bottom left of the IDE to change to “Incremental search: (search term)” – you can then type the search term you are searching for and the editor will search for it from the current source location you are on (no dialog required).<br />
<br />
    Below we did an incremental search for the term “action” and VS highlighted the first usage it found within the file:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_3F6D7528.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_0439995D.png" border="0" alt="" /></a> <br />
<br />
    We can then press “Ctrl + i” again to find the next usage of the same term (and continue this repeatedly):<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_23100D3B.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_417A4E24.png" border="0" alt="" /></a> <br />
<br />
    Pressing “Ctrl + Shift + i” will reverse direction on the search, and allow us to skip backwards.<br />
<br />
    You can press the “Esc” key at any point to escape out of incremental search.* More details on incremental search can be found <a href="http://msdn.microsoft.com/en-us/library/f27e8wzh.aspx" target="_blank">here</a>.<br />
<br />
    <b><u>F3 and Shift+F3 – Find Using Previous Search Term</u></b><br />
<br />
    One neat tip to know about incremental search is that after you press the ESC key to escape out of it, it will add the term you searched for to the find stack within the IDE.* The search term you used will show up within the “find” drop-down within the VS &quot;standard toolbar:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_794C9247.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_7807F968.png" border="0" alt="" /></a> <br />
<br />
    You can always press the F3 key within Visual Studio to repeat the last performed search at a later point.* This is particularly useful for scenarios where you search for something, make a code change, and then want to continue from that point in the code.* Just press F3 and you’ll repeat the last search (in this case “action”) from that new point in the document – no need to re-type it.<br />
<br />
    Pressing “Shift + F3” will do a reverse search (from the current cursor location in the editor) of the last search term used.* You can easily toggle using F3/Shift+F3 to search forward and backwards within your document.<br />
<br />
    <b><u>Ctrl + F3* - Find Using Current Selection</u></b><br />
<br />
    Another neat searching trick that you can use to avoid having to type your search term is to simply highlight a word (or part of a word) within the code editor, and then press “Ctrl + F3” to search for the next usage of it within the current file:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_7DE29D01.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_479174F2.png" border="0" alt="" /></a> <br />
<br />
    Pressing “Ctrl + F3” will search for the next instance of the text you have highlighted – allowing you to avoid having to type it:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_4D6C188B.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_59F9C5A7.png" border="0" alt="" /></a> <br />
<br />
    Like before, you can use “Ctrl + Shift + F3” to perform a reverse search if you so choose, to search backwards within the document.<br />
<br />
    <br />
<br />
    <br />
<br />
    <br />
<br />
    <br />
<br />
    <br />
<br />
    <br />
<br />
    <b><u>Ctrl + Shift + F – Find in Solution</u></b><br />
<br />
    Sometimes you want to search across your entire solution.* <br />
<br />
    “Ctrl + F” will bring up the find dialog and default it to search within the current document. “Shift + Ctrl + F” will bring up the find dialog and default it to instead search across the entire solution:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5FD46940.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_310EB09E.png" border="0" alt="" /></a> <br />
<br />
    Doing a search like this will bring up the “Find Results” window within the IDE and allow you to navigate to each found instance of the term:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5E239D6C.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_6010EC75.png" border="0" alt="" /></a> <br />
<br />
    You can double-click each item in the “Find Results” window to navigate to that instance of the search term you searched for.<br />
<br />
    One tip a lot of people don’t know about is the ability to press “F8” or “Shift + F8” to navigate to the next/previous instance of that search term in the list.* This can make navigating through them much faster/easier, and avoid you having to use the mouse.<br />
<br />
    <b><u>Shift + F12 - <u>Find Usages</u></u></b><br />
<br />
    Most developers using Visual Studio know how to highlight a type and press F12 to “go to definition”.* This will bring up the definition of a class/type, and is a useful way to navigate to where it is defined.<br />
<br />
    Many developers don’t know about “Shift + F12” – which brings up all usages of a particular type.* This enables you to quickly see how a particular type is used.* To take advantage of it, simply select or move the cursor onto a type and press “Shift + F12”:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_7A70DF8C.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_7F436D7B.png" border="0" alt="" /></a> <br />
<br />
    This will then bring up a “Find Symbol Results” window that list all usages of this type within the current solution:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_6A054206.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_27B229C3.png" border="0" alt="" /></a> <br />
<br />
    Like with the previous tip, you can use “F8” and “Shift F8” to navigate forward/backward within each item within the list.<br />
<br />
    <b><u>Ctrl + Minus and Shift + Ctrl + Minus - Navigate Backward/Forward</u></b><br />
<br />
    Have you ever navigated to a different code file, looked at something, and then wanted to navigate back to where you came from?* For example, you use F12 to “go to definition” and then want to return back to the code that used it?<br />
<br />
    A feature that a lot of people don’t know about in VS is the “Navigate Backwards” keystroke – “Ctrl + (minus key)”.* This will navigate to the previous document/location on the navigation stack.<br />
<br />
    To see this in action, try selecting a type in Visual Studio.* Below I’ve selected the “IController” interface:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_78803E2B.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_4BF70E45.png" border="0" alt="" /></a> <br />
<br />
    Press F12 to navigate to the definition of it.* This opens up a new editor window with the source of the selected type:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_3CE02F6B.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_0284B98A.png" border="0" alt="" /></a> <br />
<br />
    Now to jump back to where we came from, press “Ctrl + (minus key)” and VS will take us back to where we were:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_736DDAAF.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_0DCDCDC7.png" border="0" alt="" /></a> <br />
<br />
    If you want to move forward in the navigation stack (which in this case would take us back to the IController.cs file), then press the “Shift + Ctrl + (minus key)”.* <br />
<br />
    Sara Ford has a <a href="http://blogs.msdn.com/b/saraford/archive/2007/09/19/did-you-know-how-to-navigate-forward-and-backwards-in-the-editor-all-because-of-go-back-markers.aspx" target="_blank">good blog post that talks more about this feature</a>, and explains the conditions when a new location is pushed onto the navigation stack.* <br />
<br />
    <b><u>Ctrl + Alt + (down arrow) - Navigate to an Open File</u></b><br />
<br />
    Ever have a ton of files open within the IDE, and want an easy way to navigate between them?* <br />
<br />
    One useful key sequence you can use is “Ctrl + Alt + (down arrow)” – this will cause a drop-down to appear within VS that lists all open files within it:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_37CDCBEF.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_04255F91.png" border="0" alt="" /></a> <br />
<br />
    You can use the arrow keys to select the file you want to navigate to – or better yet just start typing the file-name and Visual Studio will highlight it for you within the list.* For example, above I typed “Mo” and Visual Studio highlighted “ModelBinder.cs”.* Pressing the “enter” key will navigate me to that file:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_69E4F66C.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_7A7CF15A.png" border="0" alt="" /></a> <br />
<br />
    This provides a nice, convenient, way to navigate between files without having to use the mouse or take your hands off the keyboard.* And remember that “Ctrl + (minus)” can be used to navigate you back to where you came from.<br />
<br />
    <b><u>Navigate To, View Call Hierarchy, and Highlight References Features</u></b><br />
<br />
    Visual Studio 2010 brings with it a bunch of new code navigation and searching features – including the new “Navigate To” dialog, “View Call Hierarchy” feature and Highlighted References Feature.<br />
<br />
    <img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_3634F819.png" border="0" alt="" /><br />
<br />
    I previously blogged about these three new VS 2010 features <a href="http://weblogs.asp.net/scottgu/archive/2009/10/21/searching-and-navigating-code-in-vs-2010-vs-2010-and-net-4-0-series.aspx" target="_blank">here</a>.* If you haven’t already read this post and explored these capabilities, I highly recommend doing so – they are some great additions.<br />
<br />
    <b><u>Other Editor Improvements</u></b><br />
<br />
    There are a ton of other code editor improvements in VS 2010 – many of them ones I’ve blogged about before.* Here are links to a few of my previous VS 2010 editor blog posts:<br />
<br />
    <ul><li><a href="http://weblogs.asp.net/scottgu/archive/2009/10/22/vs-2010-code-intellisense-improvements-vs-2010-and-net-4-0-series.aspx" target="_blank">Improved C#/VB code Intellisense Support</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2010/04/08/javascript-intellisense-improvements-with-vs-2010.aspx" target="_blank">Improved JavaScript code Intellisense Support</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2010/04/26/box-selection-and-multi-line-editing-with-vs-2010.aspx" target="_blank">Box Selection and Multi-Line Editing Support</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2009/09/04/asp-net-html-javascript-snippet-support-vs-2010-and-net-4-0-series.aspx" target="_blank">ASP.NET, HTML and JavaScript Snippet Support</a>   </li>
</ul>Also check out the other blog posts I’ve done in this <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx" target="_blank">VS 2010 and .NET 4 Improvements series</a>.<br />
<br />
    <b><u>Summary</u></b><br />
<br />
    Most of the above features have actually been in Visual Studio for several releases – but are ones that a surprising number of developers don’t know about.* Hopefully this blog post helps provide a convenient way to get started with them if you didn’t already know they existed.* If you need help remembering the keystrokes – print out a copy of the <a href="http://weblogs.asp.net/scottgu/archive/2010/07/29/visual-studio-2010-keyboard-shortcuts.aspx" target="_blank">VS 2010 Keybindings Poster</a> and keep it near your monitor.<br />
<br />
    To learn even more cool Visual Studio tips/tricks, subscribe to Scott Cate’s excellent <a href="http://scottcate.com/Tricks/" target="_blank">Visual Studio Tips blog series</a> (which is already up to 83 awesome tips and tricks).* Also subscribe to <a href="http://blogs.msdn.com/b/saraford/" target="_blank">Sara Ford’s blog</a> – she has an awesome set of tips/tricks that go back years.* <br />
<br />
    Hope this helps,<br />
<br />
    Scott<br />
<br />
    P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: <a href="http://www.twitter.com/scottgu" target="_blank">twitter.com/scottgu</a><br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7599141" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/24/search-and-navigation-tips-tricks-with-visual-studio.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=104311</guid>
		</item>
		<item>
			<title>Debugging Tips with Visual Studio 2010</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=104102&amp;goto=newpost</link>
			<pubDate>Thu, 19 Aug 2010 06:28:35 GMT</pubDate>
			<description><![CDATA[*Debugging Tips with Visual Studio 2010* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   This is the twenty-sixth in a series of blog posts (http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx) I’m doing on the VS 2010 and .NET 4 release. 
 
    Today’s blog post...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">Debugging Tips with Visual Studio 2010</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   This is the twenty-sixth in a <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx" target="_blank">series of blog posts</a> I’m doing on the VS 2010 and .NET 4 release.<br />
<br />
    Today’s blog post covers some useful debugging tips that you can use with Visual Studio.* My friend <a href="http://scottcate.com/" target="_blank">Scott Cate</a> (who has blogged dozens of great VS tips and tricks <a href="http://scottcate.com/Tricks/" target="_blank">here</a>) recently highlighted these to me as good tips that most developers using Visual Studio don’t seem to know about (even though most have been in the product for awhile).* Hopefully this post will help you discover them if you aren’t already taking advantage of them.* They are all easy to learn, and can help save you a bunch of time.<br />
<br />
    <b><u>Run to Cursor (Ctrl + F10)</u></b><br />
<br />
    Often I see people debugging applications by hitting a breakpoint early in their application, and then repeatedly using F10/F11 to step through their code until they reach the actual location they really want to investigate.* In some cases they are carefully observing each statement they step over along the way (in which case using F10/F11 makes sense).* Often, though, people are just trying to quickly advance to the line of code they really care about – in which case using F10/F11 isn’t the best way to do this.<br />
<br />
    Instead, you might want to take advantage of the “run to cursor” feature that the debugger supports.* Simply position your cursor on the line in your code that you want to run the application to, and then press the Ctrl + F10 keys together.* This will run the application to that line location and then break into the debugger – saving you from having to make multiple F10/F11 keystrokes to get there.* This works even if the line of code you want to run to is in a separate method or class from the one you are currently debugging. <br />
<br />
    <b><u>Conditional Breakpoints</u></b><br />
<br />
    Another common thing we often see in usability studies are cases where developers set breakpoints, run the application, try out some input, hit a breakpoint, and manually check if some condition is true before deciding to investigate further.* If the scenario doesn’t match what they are after, they press F5 to continue the app, try out some other input, and repeat the process manually.<br />
<br />
    Visual Studio’s conditional breakpoint capability provides a much, much easier way to handle this. Conditional breakpoints allow you to break in the debugger only if some specific condition that you specify is met.* They help you avoid having to manually inspect/resume your application, and can make the whole debugging process a lot less manual and tedious.<br />
<br />
    <u>How to Enable a Conditional Breakpoint</u><br />
<br />
    Setting up a conditional breakpoint is really easy.* Press F9 in your code to set a breakpoint on a particular line:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_7C83CA9C.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_5973592C.png" border="0" alt="" /></a> <br />
<br />
    Then right-click on the breakpoint “red circle” on the left of the editor and select the “Condition…” context menu:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_1F841640.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_57C28D58.png" border="0" alt="" /></a> <br />
<br />
    This will bring up a dialog that allows you indicate that the breakpoint should only be hit if some condition is true.* For example, we could indicate that we only want to break in the debugger if the size of the local paginatedDinners list is less than 10 by writing the code expression below:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_28FCD4B6.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_15DBA80A.png" border="0" alt="" /></a> <br />
<br />
    Now when I re-run the application and do a search, the debugger will only break if I perform a search that returns less than 10 dinners.* If there are more than 10 dinners then the breakpoint won’t be hit. <br />
<br />
    <u>Hit Count Feature</u><br />
<br />
    Sometimes you only want to break on a condition the Nth time it is true.* For example: only break the 5th time less than 10 dinners is returned from a search.<br />
<br />
    You can enable this by right-clicking on a breakpoint and selecting the “Hit count…” menu command. <br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_26DFD5ED.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_26077003.png" border="0" alt="" /></a> <br />
<br />
    This will bring up a dialog that allows you to indicate that the breakpoint will only be hit the Nth time a condition is met, or every N times it is met, or every time after N occurrences:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_252F0A19.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_23EA713A.png" border="0" alt="" /></a> <br />
<br />
    <u>Machine/Thread/Process Filtering</u><br />
<br />
    You can also right-click on a breakpoint and select the “Filter..” menu command to indicate that a breakpoint should only be hit if it occurs on a specific machine, or in a specific process, or on a specific thread.<br />
<br />
    <b><u>TracePoints – Custom Actions When Hitting a BreakPoint</u></b><br />
<br />
    A debugging feature that a lot of people don’t know about is the ability to use <a href="http://msdn.microsoft.com/en-us/library/232dxah7(v=VS.80).aspx" target="_blank">TracePoints</a>.* A TracePoint is a breakpoint that has some custom action that triggers when the breakpoint is hit.* This feature is particularly useful when you want to observe behavior within your application without breaking into the debugger.<br />
<br />
    I’m going to use a simple Console application to demonstrate how we might be able to take advantage of TracePoints.* Below is a recursive implementation of the <a href="http://www.hanselman.com/blog/TheWeeklySourceCode13FibonacciEdition.aspx" target="_blank">Fibonacci sequence</a>:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_1BF2CED8.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_5EA1F443.png" border="0" alt="" /></a> <br />
<br />
    In the application above, we are using Console.WriteLine() to output the final Fibonacci sequence value for a specific input.* What if we wanted to observe the Fibonacci recursive sequence in action along the way within the debugger – without actually pausing the execution of it?* TracePoints can help us easily do this.<br />
<br />
    <u>Setting up a TracePoint</u><br />
<br />
    You can enable a TracePoint by using F9 to set a breakpoint on a line of code, and then right-click on the breakpoint and choose the “When Hit…” context menu command:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_76C55E9E.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_0ADE7B28.png" border="0" alt="" /></a> <br />
<br />
    This will bring up the following dialog – which allows you to specify what should happen when the breakpoint is hit:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5C18C285.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_48F795D9.png" border="0" alt="" /></a> <br />
<br />
    Above we’ve specified that we want to print a trace message anytime the breakpoint condition is met.* Notice that we’ve specified that we want to output the value of the local variable “x” as part of the message.* Local variables can be referenced using the {variableName} syntax.* There are also built-in commands (like $CALLER, $CALLSTACK, $FUNCTION, etc) that can be used to output common values within your trace messages.<br />
<br />
    Above we’ve also checked the “continue execution” checkbox at the bottom – which indicates that we <u>do not</u> want the application to break in the debugger.* Instead it will continue running – with the only difference being that our custom trace message will be output each time the breakpoint condition is met.* <br />
<br />
    And now when we run the application, we’ll find that our custom trace messages automatically show up in the “output” window of Visual Studio – allowing us to follow the recursive behavior of the application:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_07E91675.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_721F2E17.png" border="0" alt="" /></a> <br />
<br />
    You can alternatively wire-up a custom trace listener to your application - in which case the messages you print from your TracePoints will be piped to it instead of the VS output window.<br />
<br />
    <b><u>TracePoints – Running a Custom Macro</u></b><br />
<br />
    In a talk I gave last week in London, someone in the audience asked whether it was possible to automatically output all of the local variables when a TracePoint was hit.* <br />
<br />
    This capability isn’t built-in to Visual Studio – but can be enabled by writing a custom Macro in Visual Studio, and then wiring up a TracePoint to call the Macro when it is hit.* To enable this, open up the Macros IDE within Visual Studio (Tools-&gt;Macros-&gt;Macros IDE menu command).* Then under the MyMacros node in the project explorer, select a module or create a new one (for example: add one named “UsefulThings”).* Then paste the following VB macro code into the module and save it:<br />
<br />
    *** <font color="blue">Sub</font> DumpLocals()       <br />
<br />
   <br />
<br />
    <br />
<br />
    ******* <font color="blue">Dim</font> outputWindow <font color="blue">As</font> EnvDTE.OutputWindow       <br />
<br />
   <br />
<br />
    <br />
<br />
    ******* outputWindow = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutp  ut).Object       <br />
<br />
   <br />
<br />
    <br />
<br />
          *<br />
<br />
   <br />
<br />
    <br />
<br />
    ******* <font color="blue">Dim</font> currentStackFrame <font color="blue">As</font> EnvDTE.StackFrame       <br />
<br />
   <br />
<br />
    <br />
<br />
    ******* currentStackFrame = DTE.Debugger.CurrentStackFrame       <br />
<br />
   <br />
<br />
    <br />
<br />
          *<br />
<br />
   <br />
<br />
    <br />
<br />
    ******* outputWindow.ActivePane.OutputString(<font color="#a31515">&quot;*Dumping Local Variables*&quot;</font> + vbCrLf)       <br />
<br />
   <br />
<br />
    <br />
<br />
    ******* <font color="blue">For</font> <font color="blue">Each</font> exp <font color="blue">As</font> EnvDTE.Expression <font color="blue">In</font> currentStackFrame.Locals       <br />
<br />
   <br />
<br />
    <br />
<br />
    *********** outputWindow.ActivePane.OutputString(exp.Name + <font color="#a31515">&quot; = &quot;</font> + exp.Value.ToString() + vbCrLf)       <br />
<br />
   <br />
<br />
    <br />
<br />
    ******* <font color="blue">Next </font>        <br />
<br />
     <br />
<br />
    <br />
<br />
    *** <font color="blue">End</font> <font color="blue">Sub</font>       <br />
<br />
   <br />
<br />
    <br />
<br />
    The above macro code loops through the current stack frame and dumps all local variables to the output window.<br />
<br />
    <u>Using our custom DumpLocals Custom Macro</u><br />
<br />
    We can then take advantage of our custom “DumpLocals” macro using the simple addition application below:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_742C0713.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_2C6A7E2C.png" border="0" alt="" /></a> <br />
<br />
    We’ll use F9 to set a breakpoint on the return statement within our “Add” method above.* We’ll then right-click on the breakpoint and select the “When hit” menu command:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_40839AB5.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_26AF6486.png" border="0" alt="" /></a> <br />
<br />
    This will bring up the following dialog.* Unlike before where we used the “Print a message” checkbox option and manually specified the variables we wanted to output, this time we’ll instead select the “Run a macro” checkbox and point to the custom UsefulThings.DumpLocals macro we created above:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5EEDDB9E.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_36DB2C7F.png" border="0" alt="" /></a> <br />
<br />
    We’ll keep the “continue execution” checkbox selected so that the program will continue running even when our TracePoints are hit.<br />
<br />
    <u>Running the Application</u><br />
<br />
    And now when we press F5 and run the application, we’ll see the following output show up in the Visual Studio “output” window when our Add method is invoked.* Note how the macro is automatically listing the name and value of each local variable when the TracePoint is hit:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_02C68D2C.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_1AE9F787.png" border="0" alt="" /></a> <br />
<br />
    <b><u>Summary</u></b><br />
<br />
    The Visual Studio debugger is incredibly rich.* I highly recommend setting aside some time to really learn all of its features.* The above tips and tricks are but a few of the many features it provides that most people are actually unaware of.<br />
<br />
    I’ve previously <a href="http://weblogs.asp.net/scottgu/archive/2010/04/21/vs-2010-debugger-improvements-breakpoints-datatips-import-export.aspx" target="_blank">blogged about other VS 2010 Debugger Improvements</a> (including DataTip pinning, Import/Export of Breakpoints, Preserving Last Value Variables, and more).* I’ll be doing more blog posts in the future about the new VS 2010 Intellitrace and Dump File Debugging support as well.* These provide a bunch of additional cool new capabilities that can make debugging applications (including ones in production) a lot easier and more powerful.<br />
<br />
    Also make sure to check out Scott Cate’s excellent <a href="http://scottcate.com/Tricks/" target="_blank">Visual Studio 2010 Tips and Tricks series</a> to learn more about how to best take advantage of Visual Studio.* He has an absolutely awesome set of free videos and blog posts.<br />
<br />
    Hope this helps,<br />
<br />
    Scott<br />
<br />
    P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: <a href="http://www.twitter.com/scottgu" target="_blank">twitter.com/scottgu</a><br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7596304" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/18/debugging-tips-with-visual-studio-2010.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=104102</guid>
		</item>
		<item>
			<title>“Unplugged” online chat with me this Wednesday</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=103941&amp;goto=newpost</link>
			<pubDate>Mon, 16 Aug 2010 14:00:16 GMT</pubDate>
			<description><![CDATA[*“Unplugged” online chat with me this Wednesday* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   I just got back from my trip to India and the UK last week – and will be returning to more regular blogging shortly.*  
 
    This Wednesday (August 18th) I’m going to be doing another...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">“Unplugged” online chat with me this Wednesday</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   I just got back from my trip to India and the UK last week – and will be returning to more regular blogging shortly.* <br />
<br />
    This Wednesday (August 18th) I’m going to be doing another <a href="http://events.linkedin.com/LIDNUG-Scott-Guthrie-talks-shop/pub/332616" target="_blank">online LIDNUG chat session</a>.* The chat will be from 10:00am to 11:30am Pacific Time.* I do these chats a few times a year and they tend to be pretty good.* Attendees can submit any questions they want to me, and listen to me answer them live via LiveMeeting.* You can learn more about it <a href="http://events.linkedin.com/LIDNUG-Scott-Guthrie-talks-shop/pub/332616" target="_blank">here</a> and join the chat and ask questions at the appropriate time with <a href="http://events.linkedin.com/LIDNUG-Scott-Guthrie-talks-shop/pub/332616" target="_blank">this link</a>.<br />
<br />
    Hope to get a chance to chat with some of you there!<br />
<br />
    Scott<br />
<br />
    P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: <a href="http://www.twitter.com/scottgu" target="_blank">twitter.com/scottgu</a><br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7595333" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/16/unplugged-online-chat-with-me-this-wednesday.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=103941</guid>
		</item>
		<item>
			<title>Some nice code editor features provided by the VS 2010 Power Tool Extensions</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=103470&amp;goto=newpost</link>
			<pubDate>Thu, 05 Aug 2010 09:35:30 GMT</pubDate>
			<description><![CDATA[*Some nice code editor features provided by the VS 2010 Power Tool Extensions* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   I’ve blogged (http://weblogs.asp.net/scottgu/archive/2010/07/19/vs-2010-productivity-power-tools-update-with-some-cool-new-features.aspx) in the past about the VS...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">Some nice code editor features provided by the VS 2010 Power Tool Extensions</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   I’ve <a href="http://weblogs.asp.net/scottgu/archive/2010/07/19/vs-2010-productivity-power-tools-update-with-some-cool-new-features.aspx" target="_blank">blogged</a> in the past about the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef" target="_blank">VS 2010 Productivity Power Tool Extensions</a> – a free set of Visual Studio 2010 extensions that provide some nice additional functionality.<br />
<br />
    You can read my previous blog posts about it <a href="http://weblogs.asp.net/scottgu/archive/2010/06/09/visual-studio-2010-productivity-power-tool-extensions.aspx" target="_blank">here</a> and <a href="http://weblogs.asp.net/scottgu/archive/2010/07/19/vs-2010-productivity-power-tools-update-with-some-cool-new-features.aspx" target="_blank">here</a>.* In today’s post I’m going to briefly highlight a few small, but nice, code editor capabilities that are enabled when you install the free extensions (and which I didn’t highlight in my previous blog posts).<br />
<br />
    <b><u>Ctrl+Click “Go to Definition” </u></b><br />
<br />
    One of the small, but useful, features that I find myself using a lot with the extensions is the &quot;Ctrl + Click” go to definition feature.* <br />
<br />
    For those of you who haven’t tried it, it enables you to quickly navigate to the definition of a member or type within your code.* You can accomplish the same behavior out of the box with Visual Studio by right-clicking on a member/type and then choosing the “Go to Definition” context menu item – or by moving your cursor over a type/member and then pressing the F12 key.* But for some reason I’ve found the Ctrl+Click gesture provided by the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef" target="_blank">VS 2010 Power Tool Extensions</a> more natural and faster to use (since for my keyboard the F12 key requires a split-second extra finger move to use – whereas the control key is always in easy reach).<br />
<br />
    To try out the “Ctrl+Click” behavior, just hold down the “Ctrl” key and use your mouse to hover over a type or member in your code.* When the extension is enabled you’ll find that this causes a hyperlink to appear under each type/member you hover over: <br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_52C631B7.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_5FC011C8.png" border="0" alt="" /></a> <br />
<br />
    Clicking the hyperlink will immediately navigate you to the definition of the type/member within your code:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_0A2C42E6.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_70580CB6.png" border="0" alt="" /></a> <br />
<br />
    Note that the “go-to-definition” feature in VS can also be used on a type that you don’t have source access to.* For example, like with the DbSet collection I used in my <a href="http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx" target="_blank">EF “code-first” blog post</a> yesterday:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_61AD60D1.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_15E18A18.png" border="0" alt="" /></a> <br />
<br />
    When you click a type referenced from a binary library, VS will automatically generate a class definition based on the signature compiled into the assembly:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_2E04F473.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_5AADAE4C.png" border="0" alt="" /></a> <br />
<br />
    <b><u>Triple Click Selection</u></b><br />
<br />
    Another one of the “small but useful” features provided with the power tool extensions that I find myself using a lot is the “triple click” feature.* <br />
<br />
    Today with VS you can double-click on a word to automatically select it: <br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_64929FB7.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_6AD97645.png" border="0" alt="" /></a> <br />
<br />
    When the “Triple Click” extension is enabled you can now also triple-click on a line to automatically select the entire line:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5C2ECA60.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_223F8774.png" border="0" alt="" /></a> <br />
<br />
    This behavior has been supported in Word for awhile.* Until I saw that there was a power tools extension for it I didn’t actually realize that VS didn’t already do it by default.* Well – now you can. <br />
<br />
    <b><u>“Alt Up/Down Arrow” Line Movement</u></b><br />
<br />
    Another “small but useful” feature provided by the power tool extensions is the ability to easily move lines of code up/down within the editor.* <br />
<br />
    Simply select either a single line of code, or a block of multiple lines of code, within the editor:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5C2ECA60.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_223F8774.png" border="0" alt="" /></a> <br />
<br />
    Then hold down the “alt” key, and press either the up or down arrow on your keyboard.* This will cause the editor to move the selected code up or down within the editor (without you having to copy/paste or move anything around manually):<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_5673B0BA.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_2D889BB1.png" border="0" alt="" /></a> <br />
<br />
    This is another one of those features that Word has had for awhile – and which is nice to now have in VS.<br />
<br />
    <b><u>Column Guides</u></b><br />
<br />
    Column guidelines allow you display a vertical band within the code editor.* This is useful to help identify the maximum size a single line of text should be within your code (for example: to avoid wrapping when printing it out).<br />
<br />
    The power tool extensions enable you to add a column guide pretty easily.* Just cursor over in your code editor to where you want the guideline to be (note: you can see the exact line column count at the bottom of the editor):<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_1E71BCD7.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_23E02D7B.png" border="0" alt="" /></a> <br />
<br />
    Then right-click and choose the “Guidelines-&gt;Add Guideline” menu command: <br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_42B6A159.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_3ABEFEF7.png" border="0" alt="" /></a> <br />
<br />
    This will then cause VS to show a column guide-line in all code editor windows at that column width – making it easier to see when you’ve written code or a comment that wraps beyond that:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_75A631C0.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_2D0C42EF.png" border="0" alt="" /></a> <br />
<br />
    If you want to remove a guideline, you need to move your editor cursor to be at the same column width as the guideline.* You can then right-click and use the “Guidelines-&gt;Remove Guideline” command to remove it.<br />
<br />
    <b><u>Extensions Update</u></b><br />
<br />
    In case you missed it, the Visual Studio team last week made a minor update to the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef" target="_blank">VS 2010 Productivity Power Tool Extensions</a> to fix a few bugs and performance issues that people reported with the <a href="http://weblogs.asp.net/scottgu/archive/2010/07/19/vs-2010-productivity-power-tools-update-with-some-cool-new-features.aspx" target="_blank">last release</a>.* <br />
<br />
    Sean has a blog post with more details about the update <a href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/28/fixes-for-solution-navigator-amp-quick-access-in-the-productivity-power-tools.aspx" target="_blank">here</a>.* The update included fixes for:<br />
<br />
    <ul><li>Poor performance with Solution Navigator searches on large projects. In this revision, we've made some optimizations to the search algorithm. Search will also now only be initiated after two characters are typed in the search box.</li>
<li>Items in Solution Folders were not sorted.* In this revision, they are sorted alphabetically.</li>
<li>Invoking Quick Access could cause a crash on some machine configurations. This issue has been resolved in the current revision.</li>
<li>Ctrl+1 &amp; Ctrl+2 were not configurable in the Solution Navigator, which blocked the ability to type @ on some keyboards. This revision provides the Edit.ShowSolutionNavigatorPopupForSelection &amp; Edit.ShowSolutionNavigatorPopupForFile commands which can be rebound using Tools =&gt; Options =&gt; Environment =&gt; Keyboard.   </li>
</ul><br />
    <br />
<br />
    <br />
<br />
    If you have a previous build of the Power Tool Extensions installed you use the “Tools-&gt;Extension Manager” menu command, select the power tools extension and then click the “update” button to upgrade to the latest build.* <br />
<br />
    <b><u>Summary</u></b><br />
<br />
    If you haven’t tried out the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef" target="_blank">VS 2010 Productivity Power Tool Extensions</a> yet, I’d encourage you to give it a try. It includes some nice additional functionality which can help save you keystrokes and time as you work within Visual Studio.* I’ve only covered a few of the features in this post and my previous two posts – there are a lot more cool things in there that I haven’t blogged about yet.<br />
<br />
    You can also now enable/disable each individual feature within the extensions pack – allowing you to selectively choose what you want to use.* Use the “Tools-&gt;Options” menu command, and navigate to the “Power Productivity Tools” tree-view item to enable/disable individual features. <br />
<br />
    Hope this helps,<br />
<br />
    Scott<br />
<br />
    <i>P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: </i><a href="http://www.twitter.com/scottgu" target="_blank">twitter.com/scottgu</a><br />
<br />
    <br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7578704" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/04/some-nice-code-editor-features-provided-by-the-vs-2010-power-tool-extensions.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=103470</guid>
		</item>
		<item>
			<title>Using EF “Code First” with an Existing Database</title>
			<link>http://www.cinvin.com/forums/showthread.php?t=103399&amp;goto=newpost</link>
			<pubDate>Wed, 04 Aug 2010 05:39:12 GMT</pubDate>
			<description><![CDATA[*Using EF “Code First” with an Existing Database* 
 
 
---Quote (Originally by ScottGu's Blog)--- 
   Last month I blogged (http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx) about the new Entity Framework 4 “code first” development...]]></description>
			<content:encoded><![CDATA[<div><b><i><font size="3">Using EF “Code First” with an Existing Database</font></i></b><br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				<div>
					Originally Posted by <strong>ScottGu's Blog</strong>
					
				</div>
				<div style="font-style:italic"><font face="arial"><font size="2">   Last month I <a href="http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx" target="_blank">blogged</a> about the new Entity Framework 4 “code first” development option.* EF “code-first” enables a pretty sweet <i>code-centric</i> development workflow for working with data.* It enables you to:<br />
<br />
    <ul><li>Work with data without ever having to open a designer or define an XML mapping file</li>
<li>Define model objects by simply writing “plain old classes” with no base classes required</li>
<li>Use a “convention over configuration” approach that enables database persistence without explicitly configuring anything   </li>
</ul>    In <a href="http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx" target="_blank">my initial blog post</a> I introduced EF “code-first” and demonstrated how to use the default EF4 mapping conventions to create a new database.* These default conventions work very well for new applications, and enable you to avoid having to explicitly configure anything in order to map classes to/from a database.* I then did a second <a href="http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx" target="_blank">custom database schema mapping blog post</a> that discussed how you can override the default persistence mapping rules, and enable custom database schemas.<br />
<br />
    In today’s blog post I’m going to cover a question that several people asked me recently, which is: “how do I use EF code-first with an existing database?” <br />
<br />
    <b><u>Using EF Code-First with an Existing Database</u></b><br />
<br />
    EF “Code First” works great with existing databases, and enables a very nice code-centric development approach with them. In particular, it enables you to use clean “plain old classes” (aka POCO) for your model objects, and cleanly map them to/from the database using either the default mapping conventions or by overriding them with <a href="http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx" target="_blank">custom schema mapping rules</a>.* <br />
<br />
    Below are step by step instructions on how you can use EF “Code First” with an existing database.<br />
<br />
    <b><u>Step 1: Create a new ASP.NET Web Application Project</u></b><br />
<br />
    Let’s begin by creating a new ASP.NET Web Application Project.* My previous two EF “code first” blog posts used ASP.NET MVC – for this blog post I’ll use ASP.NET Web Forms.* Note that all of the EF concepts are identical regardless of whichever type of ASP.NET application you use.<br />
<br />
    We’ll use “File-&gt;New Project” within VS 2010 (or the free Visual Web Developer 2010 Express) and choose the “ASP.NET Web application” project template to create the new application.* <br />
<br />
    The new “ASP.NET Web Application” project in VS 2010 is a nice starter template that provides a default master-page layout with CSS design (I blogged about this <a href="http://weblogs.asp.net/scottgu/archive/2009/08/26/starter-project-templates-vs-2010-and-net-4-0-series.aspx" target="_blank">new starter project template in a previous blog post</a>).* When it is created you’ll find it contains a few default files within it:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_23B10C33.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_142DFA64.png" border="0" alt="" /></a> <br />
<br />
    We don’t need these default files (we could instead just use the “Empty ASP.NET Web Application” project template) – but they’ll make our simple app look a little prettier by default so we’ll use them.<br />
<br />
    <b><u>Step 2: Reference the EF Code First Assembly</u></b><br />
<br />
    Our next step will be to add a reference to the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4e094902-aeff-4ee2-a12d-5881d4b0dd3e&amp;displaylang=en" target="_blank">EF Code First library</a> to our project.* Right click on the “references” node within the Solution Explorer and choose “Add Reference”.* <br />
<br />
    You’ll reference the “Microsoft.Data.Entity.Ctp.dll” assembly that is installed within the “\Program Files\Microsoft ADO.NET Entity Framework Feature CTP4\Binaries\” directory when you download and install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4e094902-aeff-4ee2-a12d-5881d4b0dd3e&amp;displaylang=en" target="_blank">EF Code First library</a>.* After adding this reference you’ll see it show up in your project’s references window like below:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_0C365802.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_19303813.png" border="0" alt="" /></a> <br />
<br />
    <b><u>Step 3: Northwind Database</u></b><br />
<br />
    You can skip this step if you have a SQL Server database with Northwind (or another database) installed.* <br />
<br />
    If you don’t have Northwind already installed then you can <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&amp;displaylang=en" target="_blank">download it here</a>.* You can either use the .SQL files it includes to install it into a SQL database, or copy the Northwind.mdf SQL Express file into the \App_Data directory of your application:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_783CC56B.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_574952C4.png" border="0" alt="" /></a> <br />
<br />
    <b><u>Step 4: Create our Model Layer</u></b><br />
<br />
    Now we’ll write our model classes and use EF “code first” to map them to our Northwind database.* Below is all of the code we need to write to enable this – no other code is required:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_684D80A7.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_225C4D87.png" border="0" alt="" /></a> <br />
<br />
    Below are some details about what all this code does and how it works:<br />
<br />
    <u>POCO Model Classes</u><br />
<br />
    EF “code first” enables us to use “plain old CLR objects” (aka POCO) to represent entities within a database.* This means that we do not have to derive our model classes from a base class, nor implement any interfaces or attributes on them.* This enables us to keep our model classes clean and “persistence ignorant”. <br />
<br />
    Above we’ve defined two POCO classes - “Product” and “Category” – that we’ll use to represent the “Products” and “Categories” tables within our Northwind database.* The properties on these two classes map to columns within the tables.* Each instance of a Product or Category class represents a row within the respective database tables.<br />
<br />
    <u>Nullable Columns</u><br />
<br />
    Notice that some of the properties within the “Product” class are defined as nullable (this is what int? and Decimal? means – that indicates they are nullable types).* Nullable columns within a database table should be represented within the model class as Nullable properties if they are value types:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_1F66E8D4.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_42B3DD79.png" border="0" alt="" /></a> <br />
<br />
    You can also optionally omit specifying nullable columns entirely from a model class if you don’t need to access it.* For example, the Product table within Northwind has a “QuantityPerUnit” column that is a nullable nvarchar, and a “UnitsOnOrder” column that is a nullable smallint.* I’ve omitted both of these properties from the “Product” class I defined above.* Because they are nullable within the database I can still retrieve, insert, update and delete Products without problems. <br />
<br />
    <u>Association Properties and Lazy Loading</u><br />
<br />
    EF “code-first” makes it easy to take advantage of primary-key/foreign-key relationships within the database, and expose properties on our model classes that enable us to traverse between model classes using them.<br />
<br />
    Above we exposed a “Category” property on our Product class, and a “Products” property on our Category class.* Accessing these properties enables us to use the PK/FK relationship between the two tables to retrieve back model instances.* Notice how the properties themselves are still “POCO” properties and do not require us to use any EF-specific collection type to define them.<br />
<br />
    Association properties that are marked as “virtual” will by default be lazy-loaded. What this means is that if you retrieve a Product entity, its Category information will not be retrieved from the database until you access its Category property (or unless you explicitly indicate that the Category data should be retrieved when you write your LINQ query to retrieve the Product object).* Non-virtual association properties will be loaded at the same time as their parent entity.<br />
<br />
    <u>EF Context Class</u><br />
<br />
    Once we’ve created our “Product” and “Category” POCO classes, we used EF “code first” to create a “context” class that we can use to map our POCO model classes to/from tables within the database:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_28DFA74A.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_162AAD93.png" border="0" alt="" /></a> <br />
<br />
    The “Northwind” class above is the context class we are using to map our Product and Category classes to/from the database.* It derives from the DbContext base class provided by EF “code-first”, and exposes two properties that correspond to tables within our database.* For this sample we are using the default “convention over configuration” based mapping rules to define how the classes should map to/from the database.* <br />
<br />
    We could alternatively override the “OnModelCreating” method and <a href="http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx" target="_blank">specify custom mapping rules</a> if we wanted the object model of our model classes to look differently than our database schema.* <a href="http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx" target="_blank">My previous blog EF “code first” post</a> covers how to do this.<br />
<br />
    <b><u>Step 5: Configuring our Database Connection String</u></b><br />
<br />
    We’ve written all of the code we need to write to define our model layer.* Our last step before we use it will be to setup a connection-string that connects it with our database.<br />
<br />
    In my <a href="http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx" target="_blank">initial EF “code first” blog post</a> I discussed a cool option that EF “code first” provides that allows you to have it auto-create/recreate your database schema for you.* This is a option that can be particularly useful for <a href="http://en.wikipedia.org/wiki/Greenfield_project" target="_blank">green-field development</a> scenarios – since it allows you to focus on your model layer early in the project without having to spend time on updating your database schema after each model change. <br />
<br />
    Importantly, though, the auto-create database option is just an option – it is definitely not required.* If you point your connection-string at an existing database then EF “code first” <u>will not</u> try and create one automatically. The auto-recreate option also won’t be enabled unless you explicitly want EF to do this – so you don’t need to worry about it dropping and recreating your database unless you’ve explicitly indicated you want it to do so.<br />
<br />
    For this blog post we <u>will not</u> auto-create the database.* Instead, we’ll point at the existing Northwind database we already have.* To do this we’ll add a “Northwind” connection-string to our web.config file like so:<br />
<br />
   <font size="3">     * <br />
***** <br />
*** <br />
 <br />
*    </font>    EF “code first” uses a convention where context classes by default look for a connection-string that has the same name as the context class.* Because our context class is called “Northwind” it by default looks for a “Northwind” connection-string to use.* Above our Northwind connection-string is configured to use a local SQL Express database.* You can alternatively point it at a remote SQL Server.<br />
<br />
    <b><u>Step 6: Using our Model Classes</u></b><br />
<br />
    Let’s now write a (very) simple page that uses our Northwind model classes to display some data from our database.* <br />
<br />
    We’ll begin by adding a new page to our ASP.NET project.* Right-click on the web project and choose Add-&gt;New Item, then select the “Web Form using Master Page” item template.* We’ll name the page “Products.aspx” and have it use the “Site.master” master-page that is included by default with the ASP.NET Web Project starter template.<br />
<br />
    We’ll add a  control to our new Products.aspx page.* We’ll configure it to show just the name and price of our Products:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_155247A9.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_5F6D528E.png" border="0" alt="" /></a> <br />
<br />
    Within our code-behind file we can then write the following LINQ query against our model classes to retrieve all active products from our database, and bind them to the above GridView control:* <br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_73866F17.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_59B238E8.png" border="0" alt="" /></a>*<br />
<br />
    And now when we run the project and navigate to the Products.aspx page we’ll get a listing of our Products like so:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_58D9D2FE.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_098CDAAA.png" border="0" alt="" /></a> <br />
<br />
    We now have a simple application that uses EF “code first” against an existing database.* <br />
<br />
    <b><u>Download Sample</u></b><br />
<br />
    You can download a completed version of the above sample <a href="http://www.scottgu.com/blogposts/EFCodeFirstWithDatabase.zip" target="_blank">here</a>.* It assumes you have <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4e094902-aeff-4ee2-a12d-5881d4b0dd3e&amp;displaylang=en" target="_blank">EF “code first” CTP4</a> and SQL Express installed.<br />
<br />
    <b><u>Additional Code Examples</u></b><br />
<br />
    Below are some additional code examples that demonstrate how we could use our Northwind model for other common scenarios.<br />
<br />
    <u>Query Across Relations</u><br />
<br />
    The LINQ query below demonstrates retrieve a sequence of Product objects based on the name of the Category they belong to. Notice below how we can write LINQ queries that span both the Product and a sub-property of its associated Category object.* The actual filter is all done in the database engine itself – so only Product objects get returned to the middle tier (making it efficient):<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_415F1ECD.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_19B8A2A3.png" border="0" alt="" /></a> <br />
<br />
    <u>Use the Find method to retrieve a single Product</u><br />
<br />
    In addition to allowing you to write LINQ queries, EF “Code First” also supports a “Find()” method on DbSet collections that allows you to write code like below to retrieve a single instance based on its ID:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_4DECCBE9.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_7858FD06.png" border="0" alt="" /></a> <br />
<br />
    <u>Inserting a New Category</u><br />
<br />
    The code below demonstrates how to add a new Category to the Database:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_65A4034F.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_3DFD8725.png" border="0" alt="" /></a> <br />
<br />
    Notice how we create the Category object, assign properties to it, then add it to the Context’s Categories collection.* We then call SaveChanges() on the context to persist updates to the database.<br />
<br />
    <u>Inserting a New Category and Product (and associating them)</u><br />
<br />
    The code below demonstrates how to create a new Category and a new Product, associate the Product so that it belongs to the new Category, and then save both to the Database:<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_2B488D6E.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_2A702784.png" border="0" alt="" /></a> <br />
<br />
    Notice above how we are able to have the new Product reference the newly created Category by assigning its “Category” property to point to the Category instance.* We do not need to explicitly set the CategoryID foreign key property – this will be done automatically for us when we persist the changes to the database.<br />
<br />
    EF uses an pattern called “unit of work” – which means that it can track multiple changes to a context, and then when “SaveChanges()” is called it can persist all of them together in a single atomic transaction (which means all the changes succeed or none of them do).* This makes it easier to ensure that your database can’t be left in an inconsistent state – where some changes are applied and others aren’t.* <br />
<br />
    In the code snippet above both the Category and the Product will both be persisted, or neither of them will (and an exception will be raised).<br />
<br />
    <u>Update a Product and Save it Back</u><br />
<br />
    The code below demonstrates how to retrieve and update a Product, and then save it back to the database.* Earlier I demonstrated how to use the Find() method to retrieve a product based on its ProductID.* Below we are using a LINQ query to retrieve a specific product based on its ProductName.<br />
<br />
    <a href="http://weblogs.asp.net/blogs/scottgu/image_109BF155.png" target="_blank"><img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_28BF5BB0.png" border="0" alt="" /></a> <br />
<br />
    We could make any number of changes (to any existing objects, as well as add new ones).* When we call SaveChanges() they will all be persisted in a single transaction back to the database.<br />
<br />
    <b><u>Default Conventions vs. Custom Mapping Rules</u></b><br />
<br />
    When we created the Product and Category classes earlier, we used the default conventions in EF “Code-First” to map the classes to/from the database.* This avoided the need for us to specify any custom mapping rules, and kept our code really concise.<br />
<br />
    There will definitely be times when you don’t like the shape of the database your are mapping, though, and want to have your model’s object model be different.* Refer back to my <a href="http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx" target="_blank">Custom Database Schema Mapping blog post</a> for examples of how to use EF to specify custom mapping rules.* These all work equally well when mapping existing databases.<br />
<br />
    <b><u>Summary</u></b><br />
<br />
    I’m pretty excited about the EF &quot;Code-First” functionality and think it provides a pretty nice code-centric way to work with data.* It brings with it a lot of productivity, as well as a lot of power.* In particular I like it because it helps keep code really clean, maintainable, and allows you to do a lot concisely.* Hopefully these last three blog posts about it provides a glimpse of some of the possibilities it provides – both for new and existing databases. <br />
<br />
    You can download the CTP4 release of EF Code-First <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4e094902-aeff-4ee2-a12d-5881d4b0dd3e&amp;displaylang=en" target="_blank">here</a>.* To learn even more about “EF Code-First” check out these blog posts by the ADO.NET team:<br />
<br />
    <ul><li><a href="http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4announcement.aspx" target="_blank">EF CTP4 Announcement Blog Post</a></li>
<li><a href="http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4piwalkthrough.aspx" target="_blank">EF CTP4 Productivity Enhancements Blog Post</a></li>
<li><a href="http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4codefirstwalkthrough.aspx" target="_blank">EF CTP4 Code First Walkthrough Blog Post</a></li>
<li><a href="http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-entity-framework-and-code-first.aspx" target="_blank">DataAnnotations and Code First</a></li>
<li><a href="http://blogs.msdn.com/b/efdesign/archive/2010/06/01/conventions-for-code-first.aspx" target="_blank">Default conventions with Code First</a></li>
<li><a href="http://www.hanselman.com/blog/SimpleCodeFirstWithEntityFramework4MagicUnicornFeatureCTP4.aspx" target="_blank">Scott Hanselman’s Walkthrough Post about CTP4</a>   </li>
</ul>    Hope this helps,<br />
<br />
    Scott<br />
<br />
    <i>P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: </i><a href="http://www.twitter.com/scottgu" target="_blank">twitter.com/scottgu</a><br />
<br />
 </font></font><img src="http://weblogs.asp.net/aggbug.aspx?PostID=7578351" border="0" alt="" /></div>
			
			<hr />
		</td>
	</tr>
	</table>
</div><i>(Via <a href="http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx" target="_blank">ScottGu's Blog</a>)</i></div>

]]></content:encoded>
			<category domain="http://www.cinvin.com/forums/forumdisplay.php?f=80">.Net Community</category>
			<dc:creator>Gort</dc:creator>
			<guid isPermaLink="true">http://www.cinvin.com/forums/showthread.php?t=103399</guid>
		</item>
	</channel>
</rss>
