<?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>Gary Pretty's Blog &#187; ASP.Net</title>
	<atom:link href="http://blog.garypretty.co.uk/index.php/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.garypretty.co.uk</link>
	<description>.Net Development &#38; General Tech Related News</description>
	<lastBuildDate>Wed, 19 May 2010 23:51:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Multi-Select List Box in ASP.NET MVC</title>
		<link>http://blog.garypretty.co.uk/index.php/2010/02/26/multi-select-list-box-in-asp-net-mvc/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2010/02/26/multi-select-list-box-in-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 17:13:57 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Fraemwork]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/?p=245</guid>
		<description><![CDATA[Recently I have been working on an MVC site using the Entity Framework.  I have some related entities in my EF model, as show below in the form of &#8220;Reader&#8221; and &#8220;Category&#8221;, and the relationship between them, i.e. many to many. When it came to proucing a view and action to perofrm the Create Reader [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been working on an MVC site using the Entity Framework. </p>
<p style="text-align: center;">I have some related entities in my EF model, as show below in the form of &#8220;Reader&#8221; and &#8220;Category&#8221;, and the relationship between them, i.e. many to many.<br />
<img class="aligncenter size-medium wp-image-248" style="margin: 10px; border: black 1px solid;" title="EF Model" src="http://blog.garypretty.co.uk/wp-content/model-283x300.png" alt="" width="283" height="300" /></p>
<p>When it came to proucing a view and action to perofrm the Create Reader action, I was somewhat puzzled as to how I could allow the user to select one or more categories for a reader. </p>
<p>I started by having a view model that contained a list of all possible categories and then looping around these in my view and writing a check box out for each one.  When the form was submitted I looked through the form collection to find if any of the category check boxes had been selected.  I didn&#8217;t like this one bit and so I set out to find a cleaner way of carrying it out.</p>
<p>After some (quite a lot actually) searching, I stumbled accross the MultiSelectList type, which I could use in my ViewModel and then allow the default model binding to step in and do the leg work for me <img src='http://blog.garypretty.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Great!</p>
<p>So, I created a view model, a simplified version of which you can see below;</p>
<blockquote><p>    public class ReaderCreateViewModel : CustomViewModelBase<br />
    {</p>
<p>        public ReaderCreateViewModel()<br />
        {<br />
            ReaderDetails = new Reader();<br />
            CategoriesList = GetCategories(null);<br />
        }</p>
<p>        public Reader ReaderDetails { get; set; }<br />
        public MultiSelectList CategoriesList { get; private set; }<br />
        public int[] SelectedCategories { get; set; }</p>
<p>        public MultiSelectList GetCategories(int[] selectedValues)<br />
        {<br />
            var te = new myEntities();<br />
            List&lt;Category&gt; categories = te.Categories.ToList();<br />
            return new MultiSelectList(categories, &#8220;id&#8221;, &#8220;Name&#8221;, selectedValues);<br />
        }<br />
    }</p></blockquote>
<p> As you can see from the code above, the view model contains my Reader entity, a list of type MultiSelectList, which is a list of available categories and an array of integers which represent the Id of any selected Categories.</p>
<p>Then to add a listbox to my view that will bind the MultiSelectList, I simply insert the following into my view.</p>
<blockquote><p>            &lt;p&gt;<br />
             &lt;label for=&#8221;SelectedCategories&#8221;&gt;Categories:&lt;/label&gt;<br />
        &lt;%= Html.ListBox(&#8220;SelectedCategories&#8221;, Model.CategoriesList) %&gt;<br />
            &lt;/p&gt;</p></blockquote>
<p>Finally in my controller, I can simply check the SelectedItems object in my model for any selected Ids and add them to the Reader Categories list like this;</p>
<blockquote><p>            if (model.SelectedCategories != null)<br />
            {<br />
                foreach (var selectedCat in model.SelectedCategories)<br />
                {<br />
                    int selectedCatId = selectedCat;<br />
                    Category category = DataContext.Categories.Where(c =&gt; c.id                  == selectedCatId).FirstOrDefault();<br />
                    reader.Categories.Add(category);<br />
                }<br />
            }</p></blockquote>
<p>And that&#8217;s it.  Now there is probably a much better way of doing all or some of the above, but this worked perfectly for me when I needed it, so I hope it helps someone else out as well.  The final multi-select list box looked something like this;</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/listbox.bmp"><img class="aligncenter size-full wp-image-250" title="listbox" src="http://blog.garypretty.co.uk/wp-content/listbox.bmp" alt="" /></a></p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.NET+MVC' rel='tag' target='_self'>ASP.NET MVC</a>, <a class='technorati-link' href='http://technorati.com/tag/Entity+Framework' rel='tag' target='_self'>Entity Framework</a>, <a class='technorati-link' href='http://technorati.com/tag/MVC' rel='tag' target='_self'>MVC</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2010/02/26/multi-select-list-box-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC &#8211; Passing ViewData to a MasterPage</title>
		<link>http://blog.garypretty.co.uk/index.php/2010/01/12/asp-net-mvc-passing-viewdata-to-a-masterpage/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2010/01/12/asp-net-mvc-passing-viewdata-to-a-masterpage/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:10:19 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/index.php/2010/01/12/asp-net-mvc-passing-viewdata-to-a-masterpage/</guid>
		<description><![CDATA[If like me you are using ASP.NET MVC for some of your web applications these days and use MasterPages within them, then you may have come accross the need to pass ViewData to the MasterPage.  For example, this might be for a dynamically generated navigation bar. When I first started using MVC, I simply passed [...]]]></description>
			<content:encoded><![CDATA[<p>If like me you are using ASP.NET MVC for some of your web applications these days and use MasterPages within them, then you may have come accross the need to pass ViewData to the MasterPage.  For example, this might be for a dynamically generated navigation bar.</p>
<p>When I first started using MVC, I simply passed the ViewData required for the MasterPage along with every action, but even with a small site, this was a lot of code replication.</p>
<p>To solve this problem, we can create an ApplicationController class which inherits from the Controller class we all know and love.  Your applications&#8217; controllers then in turn simply inherit from this new ApplicationController.</p>
<p>Below is a simple example of an ApplicationController.</p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">namespace</span> MvcSite.Controllers
{
    <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> ApplicationController : Controller
    {
        <span class="kwrd">private</span> MyEntities _dataContext = <span class="kwrd">new</span> MyEntities();

        <span class="kwrd">public</span> MyEntities DataContext
        {
            get { <span class="kwrd">return</span> _dataContext; }
        }

        <span class="kwrd">public</span> ApplicationController()
        {
            ViewData[<span class="str">"categories"</span>] = DataContext.Categories.ToList();
        }

    }
}</pre>
</blockquote>
<p>Hope this helps someone else as well. Certainly removed a headache for me!</p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.NET+MVC' rel='tag' target='_self'>ASP.NET MVC</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2010/01/12/asp-net-mvc-passing-viewdata-to-a-masterpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 and .Net 4.0 Beta 2 Download Available</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/10/20/visual-studio-2010-and-net-4-0-beta-2-download-available/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/10/20/visual-studio-2010-and-net-4-0-beta-2-download-available/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 09:21:37 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Betas]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[msdn]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[beta 2]]></category>
		<category><![CDATA[visual studio 2010]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/?p=233</guid>
		<description><![CDATA[Visual Studio 2010 and .Net 4.0 Beta 2 has now been released to members of MSDN, with a public download available from Wednesday. Beta 2 brings many improvements to the table, including improvements in Sharepoint, WPF, ASP.NET, WinForms, as well as improvements to the core IDE and testing tools. I saw some of these IDE improvements at [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Studio 2010 and .Net 4.0 Beta 2 has now been released to members of MSDN, with a public download available from Wednesday.</p>
<p>Beta 2 brings many improvements to the table, including improvements in Sharepoint, WPF, ASP.NET, WinForms, as well as improvements to the core IDE and testing tools. I saw some of these IDE improvements at an event with Scott Gu in Manchester a couple of weeks ago and they look pretty cool.</p>
<p>Visual Studio now comes in several flavours, namely Premium, Professional and Ultimate and the good news is that TFS 2010 comes out of the box with all three.  Apparently it only takes 20 minutes to setup source control, bug and issue tracking and automated build with it.</p>
<p>Finally, another great piece of news is that this release also ships with a Go-live license, so this can be used for production projects if you wish <img src='http://blog.garypretty.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you are a member of MSDN and want to download the beta now, you <a href="http://go.microsoft.com/fwlink/?LinkID=151797">can get it from here</a>.</p>
<p>For more information on the release visit Scott Gu&#8217;s blog where you he has started a <a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx">series of posts on the new features in 2010 Beta 2</a>.</p>
<p>Have any of you been using Beta 1? Will you be using Beta 2? What do you think of the way 2010 and .Net 4.0 are shaping up?</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/.NET+4.0' rel='tag' target='_self'>.NET 4.0</a>, <a class='technorati-link' href='http://technorati.com/tag/beta+2' rel='tag' target='_self'>beta 2</a>, <a class='technorati-link' href='http://technorati.com/tag/visual+studio+2010' rel='tag' target='_self'>visual studio 2010</a>, <a class='technorati-link' href='http://technorati.com/tag/vs2010' rel='tag' target='_self'>vs2010</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/10/20/visual-studio-2010-and-net-4-0-beta-2-download-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scott Guthrie &#8211; Manchester &#8211; September 2009 &#8211; ASP.Net 4.0, MVC, Silverlight 3, VS 2010</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/09/16/scott-guthrie-manchester-september-2009-asp-net-4-0-mvc-silverlight-3-vs-2010/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/09/16/scott-guthrie-manchester-september-2009-asp-net-4-0-mvc-silverlight-3-vs-2010/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 22:22:37 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[scott gu]]></category>
		<category><![CDATA[scott guthrie]]></category>
		<category><![CDATA[silverlight 3]]></category>
		<category><![CDATA[visual studio 2010]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/?p=223</guid>
		<description><![CDATA[Scott Guthrie, Microsoft&#8217;s Corporate Vice Presedent and all round .Net Guru is coming to Manchester, UK, later this month to talk about what&#8217;s new with Visual Studio 2010, ASP.Net 4.0, Silverlight 3 and upcoming improvements to the MVC Framework! Seating for this event, entitled Guathon 2009,  is very limited and as such you can only join the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-224 alignleft" style="margin: 20px; border: black 1px solid;" title="scottguthrie" src="http://blog.garypretty.co.uk/wp-content/scottguthrie.png" alt="scottguthrie" width="215" height="165" /></p>
<p>Scott Guthrie, Microsoft&#8217;s Corporate Vice Presedent and all round .Net Guru is coming to Manchester, UK, later this month to talk about what&#8217;s new with Visual Studio 2010, ASP.Net 4.0, Silverlight 3 and upcoming improvements to the MVC Framework!</p>
<p>Seating for this event, entitled Guathon 2009,  is very limited and as such you can only join the wait list at the moment, but I have been lucky enough to secure a place at what promises to be a fantastic workshop.</p>
<p>The announcement on the <a href="http://www.developerdeveloperdeveloper.com/guathon/">event home page over at DeveloperDeveloperDeveloper</a> also has a funny section of &#8220;things you might not know about Scott Gu&#8221;, such as;</p>
<blockquote>
<li>When Scott Guthrie throws exceptions, it’s across the room.</li>
<li>All arrays Scott Guthrie declares are of infinite size, because Scott Guthrie knows no bounds.</li>
<li>Scott Guthrie doesn’t have disk latency because the hard drive knows to hurry the hell up.</li>
<li>Scott Guthrie writes code that optimizes itself.</li>
<li>Scott Guthrie can’t test for equality because he has no equal.</li>
<li>Scott Guthrie doesn’t need garbage collection because he doesn’t call .Dispose(), he calls .DropKick().</li>
</blockquote>
<p>For the rest of this amusing list and more info on the event or to add yourself to the wait list, <a href="http://www.developerdeveloperdeveloper.com/guathon/" target="_blank">visit the event home page</a>.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.Net' rel='tag' target='_self'>ASP.Net</a>, <a class='technorati-link' href='http://technorati.com/tag/ASP.NET+MVC' rel='tag' target='_self'>ASP.NET MVC</a>, <a class='technorati-link' href='http://technorati.com/tag/scott+gu' rel='tag' target='_self'>scott gu</a>, <a class='technorati-link' href='http://technorati.com/tag/scott+guthrie' rel='tag' target='_self'>scott guthrie</a>, <a class='technorati-link' href='http://technorati.com/tag/silverlight+3' rel='tag' target='_self'>silverlight 3</a>, <a class='technorati-link' href='http://technorati.com/tag/visual+studio+2010' rel='tag' target='_self'>visual studio 2010</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/09/16/scott-guthrie-manchester-september-2009-asp-net-4-0-mvc-silverlight-3-vs-2010/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BOOK REVIEW: Professional Refactoring in C# and ASP.NET (Wrox)</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/08/07/book-review-professional-refactoring-in-c-and-asp-net-wrox/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/08/07/book-review-professional-refactoring-in-c-and-asp-net-wrox/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 10:37:11 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[wrox]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/index.php/2009/08/07/book-review-professional-refactoring-in-c-and-asp-net-wrox/</guid>
		<description><![CDATA[Title: Professional Refactoring in C# and ASP.Net Publisher: Wrox Author: Danijel Arsenovski Even the most experienced developers can sometimes be found sat staring at their monitor trying to decide which way to implement a solution. Asking a fellow developer for input will probably result in more avenues to consider as opposed to narrowing down the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.garypretty.co.uk/wp-content/refact.jpg"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px 20px 0px; border-top: 0px; border-right: 0px" src="http://blog.garypretty.co.uk/wp-content/refact_thumb.jpg" border="0" alt="refact" width="163" height="204" align="left" /></a></p>
<p><strong>Title:</strong> Professional Refactoring in C# and ASP.Net</p>
<p><strong>Publisher:</strong> Wrox</p>
<p><strong>Author:</strong> Danijel Arsenovski</p>
<p>Even the most experienced developers can sometimes be found sat staring at their monitor trying to decide which way to implement a solution. Asking a fellow developer for input will probably result in more avenues to consider as opposed to narrowing down the initial choice. But all things considered if the end result meets the user’s requirements does it really matter which design choice we make?</p>
<p>Well&#8230;&#8230;yes. The code will still need to be maintained and updated; this can be time consuming if the code is unstructured or messy. However with some refactoring techniques to follow it’s possible to make the right decisions during design and implementation and this book contains the techniques to help you make those decisions.</p>
<p><strong><br />
Why did I read this book?</strong></p>
<p>I’ve read a couple of books on the subject of refactoring, these where mainly concerned with the business logic layer side of applications so I was interested in what this book had to say about refactoring ASP.Net.</p>
<p><strong><br />
First Impressions</strong></p>
<p>The book starts with a good introduction of refactoring including its benefits and also spends some time “Debunking Common Misconceptions” (one or two I’ve firsthand experience of trying to dismiss) and “Smells”. This isn’t a scratch and sniff section but a way of identifying code that is a candidate for refactoring. Throughout the book Smells will be introduced along with ways to detect them, which refactoring technique to use to eliminate them and the rational for removing them.</p>
<p>The Introduction chapter includes an index of the Smells as well as Refactorings and Object-Orientated Design Principles so they can be quickly found and referenced. I found this to be really useful as I was working my way through the book. </p>
<p><strong><br />
What’s Covered</strong></p>
<p>In the words of the book;</p>
<blockquote><p>&#8220;This book covers the refactoring techniques that will enable you to become more efficient and productive. You will be able to use this information to respond to change and improve the design of existing code&#8221;.</p></blockquote>
<p>In my opinion this book does indeed go a long way to achieving the above statement.</p>
<p>The book covers the following areas;</p>
<ul>
<li>Assembling a refactoring toolkit</li>
<li>Techniques for performing unit testing </li>
<li>Tips on refactoring to patterns</li>
<li>Using refactoring to upgrade legacy C# and ASP.Net code</li>
<li>Using method extraction to eliminate duplicated code</li>
<li>Making code more simple and easier to understand</li>
<li>OO theory and design patterns</li>
<li>Methods for using LINQ and C# 3.0 enhancements</li>
</ul>
<p><strong><br />
What I Liked?</strong></p>
<p>I enjoyed the chapters on “LINQ and Other C# 3.0 Enhancements” and “Refactoring ASP.NET Applications” which I found very insightful and will be using some of these techniques in the future.</p>
<p>Most of this book is, obviously, based around Refactoring Techniques and these chapters are very well presented with good code examples. I like the way that the Smells and Refactorings are emphasised throughout the chapters as this reinforces the point being made as well as making the sections easier to locate when you want to reference them.</p>
<p>Although I have read about refactoring before I did enjoy reading through these chapters which reinforced what I had previously read and having the examples in C# was a real advantage as this is the language that I currently develop with.</p>
<p><strong><br />
What Could Be Better?</strong></p>
<p>I’m a big advocate of Test Driven Development (TDD) and I think that this methodology is key when refactoring. Always having a number of tests for the code that you are refactoring allows you the confidence to alter the code knowing that if your change was to impact an area you weren’t expecting this would be highlighted to you with a failed test. Although this is mentioned in this book I think that this should have been given more emphasis.</p>
<p><strong><br />
The Final Verdict</strong></p>
<p>All in all this was a good and worthwhile read and although I would not recommend relying on simply this book for all areas of knowledge of this subject (i.e. TDD), I would certainly recommend the book to my peers.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.Net' rel='tag' target='_self'>ASP.Net</a>, <a class='technorati-link' href='http://technorati.com/tag/book+review' rel='tag' target='_self'>book review</a>, <a class='technorati-link' href='http://technorati.com/tag/C%23' rel='tag' target='_self'>C#</a>, <a class='technorati-link' href='http://technorati.com/tag/refactoring' rel='tag' target='_self'>refactoring</a>, <a class='technorati-link' href='http://technorati.com/tag/wrox' rel='tag' target='_self'>wrox</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/08/07/book-review-professional-refactoring-in-c-and-asp-net-wrox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Expression Web 3 Released</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/07/26/expression-web-3-released/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/07/26/expression-web-3-released/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 23:39:47 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Expression Web]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[msdn]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[expression studio]]></category>
		<category><![CDATA[expression web 3]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/?p=147</guid>
		<description><![CDATA[Expression Web 3, part of Expression Studio from Microsoft has now been released and is available for purchase / download. MSDN license holders should find Expression Studio including Expression Web 3 available for download now from the MSDN web site, whilst everyone else can take advantage of free trials (the Expression Web 3 trail can be [...]]]></description>
			<content:encoded><![CDATA[<p>Expression Web 3, part of Expression Studio from Microsoft has now been released and is available for purchase / download.</p>
<p>MSDN license holders should find Expression Studio including Expression Web 3 available for download now from the MSDN web site, whilst everyone else can take advantage of free trials (the <a href="http://www.microsoft.com.nsatc.net/downloads/details.aspx?familyid=0A73A3A7-3E06-4125-B3C6-F9C10387E9CC&amp;displaylang=en" target="_blank">Expression Web 3 trail can be downloaded here</a> and is around 122mb) and upgrade offers, where appropriate.</p>
<p>Expression Web 3 brings some exciting stuff to the table to improve on the already popular Expression Web 2.</p>
<p>Amongst the most notable features are;</p>
<ul>
<li>Brand new look and feel to match the darker style seen in Expression Blend 2.</li>
</ul>
<div class="wp-caption alignnone" style="width: 515px"><img src="http://www.microsoft.com/expression/media/xWeb1.jpg" alt="Image used taken from Expression Web site from Microsoft. Coptright Microsoft." width="505" height="402" /><p class="wp-caption-text">Image used taken from Expression Web site from Microsoft. Coptright Microsoft.</p></div>
<ul>
<li>SuperPreview &#8211; allowing you to view your pages / sites in multiples browsers and examine and resolve any cross browser compatibility issues with your designs.</li>
<li>SnapShot Preview &#8211; A browser preview that automatically updates side by side with your design / code, meaning that you do not have to load the browser everytime you make a change to see what it will render like.
<p><div class="wp-caption alignnone" style="width: 506px"><img src="http://www.microsoft.com/expression/media/xWeb2.png" alt="Image used taken from Expression Studio Web Site from Microsoft. Copyright Microsoft." width="496" height="448" /><p class="wp-caption-text">Image used taken from Expression Studio Web Site from Microsoft. Copyright Microsoft.</p></div></li>
<li>Silverlight and DeepZoom support &#8211; You can now embed Silverlight movies as well as DeepZoom movies into your pages using Expression Web 3.</li>
<li>Improved FTP Publishing and Site Management &#8211; Expression Web 3 now claims to upload and sync your sites with your remote server faster than before, uploading multiple files at once.  It now also boasts improved site management which should make switching between sites and saving associated settings a breeze.</li>
<li>Internet Explorer 8 Support &#8211; Support for IE8 now comes with EW3 allowing you to target web sites for this browser.</li>
<li>Expression Design 3 Included &#8211; The graphical editor from Microsoft, Expression Design is now included with Expression Web.</li>
</ul>
<p>Also released as part of Expression Studio 3 are the new versions of Expression Blend, Expression Encoder and,  as already mentioned, Expression Design.</p>
<p>I have only just installed the new version of the studio, but will post some follow ups of anything interesting I think would be worth sharing.</p>
<p>Below are some links to pages for Expression Web 3 and Expression Studio 3;</p>
<p><a href="http://www.microsoft.com/expression/" target="_blank">Expression 3 Web Site</a></p>
<p><a href="http://www.microsoft.com.nsatc.net/downloads/details.aspx?familyid=0A73A3A7-3E06-4125-B3C6-F9C10387E9CC&amp;displaylang=en" target="_blank">Expression Web 3 Trial Download</a></p>
<p><a href="http://www.microsoft.com/expression/products/Web_Overview.aspx" target="_blank">Expression Web 3 Product Information</a></p>
<p>Let me know your thoughts on the new versions&#8230;.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/expression+studio' rel='tag' target='_self'>expression studio</a>, <a class='technorati-link' href='http://technorati.com/tag/Expression+Web' rel='tag' target='_self'>Expression Web</a>, <a class='technorati-link' href='http://technorati.com/tag/expression+web+3' rel='tag' target='_self'>expression web 3</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/07/26/expression-web-3-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight 3 and Expression 3 Uk Lunch Event in July</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/07/01/silverlight-3-and-expression-3-uk-lunch-event-in-july/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/07/01/silverlight-3-and-expression-3-uk-lunch-event-in-july/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:01:54 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Expression Web]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[expression 3]]></category>
		<category><![CDATA[silverlight 3]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/index.php/2009/07/01/silverlight-3-and-expression-3-uk-lunch-event-in-july/</guid>
		<description><![CDATA[UPDATE: Expression Web 3, Sliverlight 3 and Expression Studio 3 have now been released, which you can read about in my post, &#8220;Expression Web 3 Released&#8221; here. I received an email this morning inviting me to an exclusive launch event for Silverlight 3 and Expression 3. Unfortunately I am out of the country, but the launch [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: Expression Web 3, Sliverlight 3 and Expression Studio 3 have now been released, which you can read about in my post, </strong><a href="http://blog.garypretty.co.uk/index.php/2009/07/26/expression-web-3-released/"><strong>&#8220;Expression Web 3 Released&#8221; here</strong></a><strong>.</strong></p>
<p><a href="http://blog.garypretty.co.uk/wp-content/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://blog.garypretty.co.uk/wp-content/image_thumb.png" border="0" alt="image" width="530" height="204" /></a></p>
<p>I received an email this morning inviting me to an exclusive launch event for Silverlight 3 and Expression 3.</p>
<p>Unfortunately I am out of the country, but the launch event is being held by Microsoft on July 22nd.</p>
<p>In the words of the invite, the event is to “celebrate the UK launch of Silverlight 3 and Expression 3” and will feature a keynote speaker in the form of PP&amp;T General Manager, <a href="http://twitter.com/IanET" target="_blank">Ian Ellison-Taylor</a> of Microsoft in Redmond.</p>
<p>So, it looks like we will be seeing the launch Expression 3 and Silverlight 3 on or around July 22nd 2009.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/expression+3' rel='tag' target='_self'>expression 3</a>, <a class='technorati-link' href='http://technorati.com/tag/microsoft' rel='tag' target='_self'>microsoft</a>, <a class='technorati-link' href='http://technorati.com/tag/silverlight+3' rel='tag' target='_self'>silverlight 3</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/07/01/silverlight-3-and-expression-3-uk-lunch-event-in-july/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BOOK REVIEW: ASP.Net MVC 1.0, Problem &#8211; Design &#8211; Solution (Wrox)</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/06/29/book-review-asp-net-mvc-1-0-problem-design-solution-wrox/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/06/29/book-review-asp-net-mvc-1-0-problem-design-solution-wrox/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:03:19 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[wrox]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/index.php/2009/06/29/book-review-asp-net-mvc-1-0-problem-design-solution-wrox/</guid>
		<description><![CDATA[Title: ASP.NET MVC 1.0 Problem – Design – Solution Publisher: Wrox Authors: Nick Beradi, Al Katawazi, Marco Bellinaso It seems that recently every man and his dog have been talking about ASP.Net MVC and the many advantages it brings along with it.  I have to admit that, up until now, I have not really looked [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://blog.garypretty.co.uk/wp-content/mvcbook.jpg"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 35px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="mvcbook" src="http://blog.garypretty.co.uk/wp-content/mvcbook_thumb.jpg" border="0" alt="mvcbook" width="244" height="244" align="left" /></a> Title:</strong> ASP.NET MVC 1.0 Problem – Design – Solution</p>
<p><strong>Publisher:</strong> Wrox</p>
<p><strong>Authors:</strong> Nick Beradi, Al Katawazi, Marco Bellinaso</p>
<p>It seems that recently every man and his dog have been talking about ASP.Net MVC and the many advantages it brings along with it.  I have to admit that, up until now, I have not really looked into it a great deal, except for watching a couple of sessions at last years MSDN Roadshow.  Anyway, I decided that it was about time I found out more about ASP.Net MVC and see if it really was worth all of the hype.</p>
<p><strong></strong></p>
<p>Why did I read THIS book?</p>
<p>The reason I chose this book was two fold – firstly, it claimed to give you a good grounding in using ASP.Net MVC to those with experience of ASP.Net Web Development.  Secondly, in the books’ own words it provided “solid, workable solutions to real work problems” (I was dubious about this claim….many books I have read have claimed to do this and failed miserably with the first couple of chapters).</p>
<p><strong><br />
First Impressions</strong></p>
<p>Right from the very first chapter it starts off on the correct foot, giving an overview of the application you will create as you work through the book, that application being The Beer House, which is available for download as a starter kit.  The main attraction of this application to me was that it contained many of the features I often implement in my own applications, such as forums, article management and user profile / membership management.  The idea of reading a book that directly relates to my real-world programming was a big pull for me.</p>
<p>Thankfully, this book certainly does not try and force MVC down your throat as a must-use solution, instead giving an honest opinion that, yes MVC is very useful in many situations, but that in other situations, classic ASP.Net Web Forms may still be the more logical option.  This is a refreshing change from some of the other more self-righteous books I have had the des-pleasure of sampling where they simply see their subject matter and related methods as the only way to go.</p>
<p><strong><br />
What’s Covered?</strong></p>
<p>I don’t think I can put the content of the book in better words that the book itself, so here are those very words;</p>
<li>Techniques for building a flexible, easily configurable, and instrumented site</li>
<li>How to use jQuery to enhance and extend the capabilities of your ASP.NET MVC site</li>
<li>How to design a module to manage articles, news, and blog posts</li>
<li>Tips for creating and managing multiple polls on your site</li>
<li>Ways to build a robust newsletter system for e–mail newsletters on a background thread</li>
<li>How to develop a Web 2.0 community–centric forum from scratch</li>
<li>Steps for adding a working e–commerce store based on PayPal</li>
<li>All the different ways to deploy an ASP.NET MVC site</li>
<p>All of the above is covered in ample detail and I really did find this book extremely useful when relating the MVC implementation with my tradition Web Forms methods.</p>
<p>I especially liked the fact that attention was paid to the design of the application you create.  Coming from a web design background I am often astounded by the lack of attention paid to this area and it was pleasing to see a chapter dedicated to this for the non-design minded developer.</p>
<p>The other thing I loved about this book was that as well as ensuring every detail was covered off when developing each solution for the Beer House application, the authors have made a clear effort to highlight when something more may be needed in different circumstances and provided sample code and examples where needed.</p>
<p><strong><br />
Source Code Problems</strong></p>
<p>Probably the only bad thing I have to say about this book were the problems I had when attempting to get the source code to compile once I had downloaded it from the Wrox web site.  I think the main problem was that the code on the site was possibly an old version with several other versions kicking around the internet.  I am unsure as to which was the correct up-to-date copy.</p>
<p>However, all that said, with some tinkering, I did manage to get it to compile and what a lovely application it is. <img src='http://blog.garypretty.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong><br />
The Final Verdict</strong></p>
<p>I found this book to be an extremely concise and focused journey through ASP.Net MVC and a perfect introduction to the subject and I would highly recommend it to anybody who is looking for a good grounding in the subject.</p>
<p>This was also my first read of a book from the <strong>Problem – Design – Solution </strong>series from Wrox, and if the other books in the series are in a similar style, then I look forward to reading more as the straight forward style with real-world connections suited me down to the ground.  </p>
<p>You can find this book <a href="http://www.amazon.co.uk/ASP-NET-MVC-1-0-Website-Programming/dp/0470410957" target="_blank">for sale on Amazon</a> or from <a href="http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470410957.html" target="_blank">the Wiley web site</a>.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.Net' rel='tag' target='_self'>ASP.Net</a>, <a class='technorati-link' href='http://technorati.com/tag/ASP.NET+MVC' rel='tag' target='_self'>ASP.NET MVC</a>, <a class='technorati-link' href='http://technorati.com/tag/book+review' rel='tag' target='_self'>book review</a>, <a class='technorati-link' href='http://technorati.com/tag/C%23' rel='tag' target='_self'>C#</a>, <a class='technorati-link' href='http://technorati.com/tag/wrox' rel='tag' target='_self'>wrox</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/06/29/book-review-asp-net-mvc-1-0-problem-design-solution-wrox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TUTORIAL: Entity Framework v2.0 &#8211; Model First using Visual Studio 2010 and .Net 4.0</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/05/20/tutorial-entity-framework-v20-model-first-using-visual-studio-2010-and-net-40/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/05/20/tutorial-entity-framework-v20-model-first-using-visual-studio-2010-and-net-40/#comments</comments>
		<pubDate>Wed, 20 May 2009 14:36:56 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ado.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[.net 4]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[visual studio 2010]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/index.php/2009/05/20/tutorial-entity-framework-v20-model-first-using-visual-studio-2010-and-net-40/</guid>
		<description><![CDATA[Following up on my recent post about the improvements to the Entity Framework in .Net 4.0 this is the first in a series of posts examining some of the new features and showing you how to put some of them into practice. In this post I am going to look at one of the most [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my recent post about the improvements to the Entity Framework in .Net 4.0 this is the first in a series of posts examining some of the new features and showing you how to put some of them into practice.</p>
<p>In this post I am going to look at one of the most anticipated features, Model First.  In the first version of the Entity Framework, you took a pre-existing database and the tools would generate your entity model for you.  In v2.0, you now have the option of creating your entity model first and then generating your database DDL from your finished model.</p>
<p>To follow this tutorial you will need Visual Studio 2010 Beta 1, .Net Framework 4.0 Beta 1 installed, SQL 2005 or 2008 / SQL Express.</p>
<p><strong><span style="color: #ff8000;">Please bear with me and let me know if there are any parts of this tutorial that are not completely clear.  I am new to writing these! So any comments welcome….</span></strong></p>
<p><strong>Creating your project and adding your blank entity model</strong></p>
<p>Open Visual Studio 2010 and create a new Dynamic Data Entities Web Application project(you could another project type to host your entity model, such as an ASP.Net Web Application).</p>
<p>Once your project has been created add a new <strong>ADO.Net Entity Data Model </strong>to the project. </p>
<p><a href="http://blog.garypretty.co.uk/wp-content/add-model-object.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="add_model_object" src="http://blog.garypretty.co.uk/wp-content/add-model-object-thumb.gif" border="0" alt="add_model_object" width="523" height="364" /></a></p>
<p>You will then be asked about what the model should contain.  As with version 1 of the Entity Framework, you have two options, <em>Generate from Database </em>and <em>Empty Model</em>.  To a large extent, the latter was redundant in the first version of the framework, but with version 2 it becomes very useful.  Select <strong><em>Empty Model</em></strong> and click Finish.<span id="more-121"></span></p>
<p><a href="http://blog.garypretty.co.uk/wp-content/choose-empty-model.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="choose_empty_model" src="http://blog.garypretty.co.uk/wp-content/choose-empty-model-thumb.gif" border="0" alt="choose_empty_model" width="526" height="467" /></a></p>
<p><strong></strong></p>
<p><strong><br />
Adding an entity and scalar properties to your model</strong></p>
<p>You will now be presented with your empty model designer ready for you to add your entities.  Right click on the designer and select <strong>Add –&gt; Entity…  </strong>For this example we will name our entity “Customer” and the entity set “Customers”.  This will create your Customer entity in the designer.</p>
<p>You will now need to add some properties to the entity.  You can do this by right clicking the entity and <strong>Add –&gt; Scalar Property </strong>and then selecting the data type of the property. Do this and create two string scalar properties for Name and Email.</p>
<p><strong></strong></p>
<p><strong><br />
Adding complex types</strong></p>
<p>You should now have a Customer entity with properties for the customer’s name and email address. A complex type is essentially a property that can contain sub properties.  To display this we are going to create one for the customer’s mailing address.</p>
<p>In your model browser, right click on the “Complex Types” folder and select <strong>Create Complex Type</strong>.  Rename this created type “Address”.  Now right click on the <strong>Address </strong>object you have created and select <strong>Add –&gt; Scalar Property –&gt; String</strong>.  Rename the created property “Line 1”.  Repeat this, adding properties for Line 2, Town, County, Post Code (you could use City, State, Zip if you are in the U.S. for example).</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/entity-created-add-scalar.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="entity_created_add_scalar" src="http://blog.garypretty.co.uk/wp-content/entity-created-add-scalar-thumb.gif" border="0" alt="entity_created_add_scalar" width="531" height="246" /></a></p>
<p>Once you have created your complex type, you can add this to your Customer entity by right clicking the entity and selecting <strong>Add –&gt; Complex Property</strong>. If you name your property Address, then the property type should automatically be set to <em>Address</em>, which is what we have just created.  You can check this and alter the type via the properties of the complex property (that’s a lot of properties <img src='http://blog.garypretty.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p> </p>
<p><strong>Create some additional entities</strong></p>
<p>Once I had created my Customer entity, I then went through the same steps to create two additional entities for <strong>Order</strong> and <strong>Product</strong>. If you do this, then you should end up with something like below.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/finished-entities.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="finished_entities" src="http://blog.garypretty.co.uk/wp-content/finished-entities-thumb.gif" border="0" alt="finished_entities" width="531" height="419" /></a></p>
<p><strong></strong></p>
<p><strong><br />
Adding entity associations</strong></p>
<p>Now that we have our entities for Customer, Order and Product, we need to tell the model how the entities are associated.  For example, a customer will have related orders and an order will have related products.</p>
<p>To add our first association, right click the Customer entity and select <strong>Add –&gt; Association</strong>. You will then be presented with the dialog shown below to actually define the association.  As you can see, the primary entity for this association is Customer which is related to Order with a multiplicity of one-to-many.  Here is where we also set the navigation properties which will allow us to access related entities.  So for example, the Customer entity will have a navigation property of “Orders”.  There is also a plain English description of the association you are about to create to ensure that you are creating it correctly.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/create-association.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="create_association" src="http://blog.garypretty.co.uk/wp-content/create-association-thumb.gif" border="0" alt="create_association" width="530" height="508" /></a>  </p>
<p>Once you are happy click ok and the association will be shown on your model connecting the Customer and Order entities.</p>
<p>We now need to also create an association between the Order and Product entities using the same steps as above, but this time the properties of the association are slightly different as the multiplicity is many-to-many as show below.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/manytomanyassociation.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="many-to-many-association" src="http://blog.garypretty.co.uk/wp-content/manytomanyassociation-thumb.gif" border="0" alt="many-to-many-association" width="534" height="512" /></a></p>
<p><strong></strong></p>
<p><strong><br />
Generating the database</strong></p>
<p>Ok, so we have our model containing our entities.  Our entities have their properties and their associations, but we still do not have a database for our model to map to.  This is the bit I really like.  Right click on the model designer area and click “<strong>Generate Database Script From Model…</strong>”.</p>
<p>This will then open the standard database connection dialog we are all used to in Visual Studio. Add a connection, select your server and enter a name for your database (use a name that does not already exist, I called mine “ModelFirstTestDb”…..original I know!), then click OK.  You should then be prompted to create the database as seen below, so click Yes to create the database.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/confirm-database-create.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="confirm_database_create" src="http://blog.garypretty.co.uk/wp-content/confirm-database-create-thumb.gif" border="0" alt="confirm_database_create" width="532" height="543" /></a></p>
<p>You should now see your new connection selected and the option to store the credentials in the web.config should be checked. Click next and the database schema scripts (DDL) will be generated for you and you will be presented with the generated script as below.  Take a minute to have a look through the DDL and see how it has created the tables and fields.  In the image below you can see the fields that have been generated to map to the complex type for the Customer address we created earlier.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/generated-ddl.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="generated_ddl" src="http://blog.garypretty.co.uk/wp-content/generated-ddl-thumb.gif" border="0" alt="generated_ddl" width="535" height="517" /></a></p>
<p>Now we just need to click Finish and we will be warned that our existing mappings and store schema will be overwritten, click Yes to continue.</p>
<p><a href="http://blog.garypretty.co.uk/wp-content/ssdl-warning.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="ssdl_warning" src="http://blog.garypretty.co.uk/wp-content/ssdl-warning-thumb.gif" border="0" alt="ssdl_warning" width="434" height="129" /></a></p>
<p><strong></strong></p>
<p><strong><br />
Execute your DDL</strong></p>
<p>Now you need to take the generated script and execute it against your database.  The database itself will have been created, but in this beta version you still need to execute the scripts manually.  The ADO.Net team have indicated that this will not be the case in the final version.</p>
<p><strong></strong></p>
<p><strong><br />
Running your Dynamic Data Entities application</strong></p>
<p>If you now open the Global.asax.cs file in your project and add the following line in the RegisterRoutes method, you should be able to run your application and see your new model and database in action;</p>
<p><span style="font-size: xx-small;"><strong>DefaultModel.RegisterContext(typeof(Model1Container),new ContextConfiguration() { ScaffoldAllTables = true });</strong></span></p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/.net+4' rel='tag' target='_self'>.net 4</a>, <a class='technorati-link' href='http://technorati.com/tag/ado.net' rel='tag' target='_self'>ado.net</a>, <a class='technorati-link' href='http://technorati.com/tag/Entity+Framework' rel='tag' target='_self'>Entity Framework</a>, <a class='technorati-link' href='http://technorati.com/tag/tutorial' rel='tag' target='_self'>tutorial</a>, <a class='technorati-link' href='http://technorati.com/tag/visual+studio+2010' rel='tag' target='_self'>visual studio 2010</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/05/20/tutorial-entity-framework-v20-model-first-using-visual-studio-2010-and-net-40/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Typemock for ASP.NET Unit Testing</title>
		<link>http://blog.garypretty.co.uk/index.php/2009/05/19/typemock-for-aspnet-unit-testing/</link>
		<comments>http://blog.garypretty.co.uk/index.php/2009/05/19/typemock-for-aspnet-unit-testing/#comments</comments>
		<pubDate>Tue, 19 May 2009 12:39:27 +0000</pubDate>
		<dc:creator>Gary Pretty</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[typemock]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://blog.garypretty.co.uk/?p=98</guid>
		<description><![CDATA[This is fresh from the typemock.com blog; Unit Testing ASP.NET? ASP.NET unit testing has never been this easy. Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle &#8211; and for the launch will be giving out FREE licenses to bloggers and their readers. The ASP.NET Bundle is the ultimate ASP.NET unit [...]]]></description>
			<content:encoded><![CDATA[<p>This is fresh from the <a href="http://blog.typemock.com">typemock.com blog</a>;</p>
<p><a href="http://www.typemock.com/"><span style="color: #006699;">Unit Testing</span></a> ASP.NET? <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php"><span style="color: #006699;">ASP.NET unit testing</span></a> has never been this easy.</p>
<p>Typemock is launching a new product for ASP.NET developers – the <strong>ASP.NET Bundle</strong> &#8211; and for the launch will be giving out <span style="color: #000000;"><span style="color: #006600;"><strong>FREE licenses</strong></span> to bloggers and their readers.</p>
<p>The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both </span><a href="http://www.typemock.com/"><span style="color: #006699;">Typemock Isolator</span></a>, a <a href="http://www.typemock.com/"><span style="color: #006699;">unit test</span></a> tool and <a href="http://sm-art.biz/Ivonna.aspx"><span style="color: #006699;">Ivonna</span></a>, the Isolator add-on for <a href="http://sm-art.biz/Ivonna.aspx"><span style="color: #006699;">ASP.NET unit testing</span></a>, for a bargain price.</p>
<p>Typemock Isolator is a leading <a href="http://www.typemock.com/"><span style="color: #006699;">.NET unit testing</span></a> tool (C# and VB.NET) for many ‘hard to test’ technologies such as <a href="http://typemock.com/sharepointpage.php"><span style="color: #006699;">SharePoint</span></a>, <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php"><span style="color: #006699;">ASP.NET</span></a>, <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php"><span style="color: #006699;">MVC</span></a>, <a href="http://www.typemock.com/wcfpage.php"><span style="color: #006699;">WCF</span></a>, WPF, <a href="http://www.typemock.com/Silverlight_unit_testing_page.php"><span style="color: #006699;">Silverlight</span></a> and more. Note that for <a href="http://www.typemock.com/Silverlight_unit_testing_page.php"><span style="color: #006699;">unit testing Silverlight</span></a> there is an open source Isolator add-on called <a href="http://www.typemock.com/Silverlight_unit_testing_page.php"><span style="color: #006699;">SilverUnit</span></a>.</p>
<p>The first 60 bloggers who will blog this text in their blog and <a href="http://blog.typemock.com/2009/05/get-free-typemock-licenses-aspnet.html"><span style="color: #006699;">tell us about it</span></a>, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET <strong>dedicated</strong> blog, you&#8217;ll get a license automatically (even if more than 60 submit) during the first week of this announcement.</p>
<p>Also 8 bloggers will get an <strong>additional 2 licenses</strong> (each) to give away to their readers / friends.</p>
<p>Go ahead, click the following link for <a href="http://blog.typemock.com/2009/05/get-free-typemock-licenses-aspnet.html"><span style="color: #006699;">more information </span></a>on how to get your free license.</p>

<!-- start wp-tags-to-technorati 1.01 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/ASP.Net' rel='tag' target='_self'>ASP.Net</a>, <a class='technorati-link' href='http://technorati.com/tag/typemock' rel='tag' target='_self'>typemock</a>, <a class='technorati-link' href='http://technorati.com/tag/unit+testing' rel='tag' target='_self'>unit testing</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://blog.garypretty.co.uk/index.php/2009/05/19/typemock-for-aspnet-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
