<?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>PrimeDigit - A Design Blog by Will Shaver &#187; ASP.Net</title>
	<atom:link href="http://www.primedigit.com/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.primedigit.com</link>
	<description>Thoughts on ASP.NET, Visual Design, SQL Server 2005, C# and much more...</description>
	<lastBuildDate>Tue, 29 Jun 2010 16:33:50 +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>MVC RC1</title>
		<link>http://www.primedigit.com/2009/01/28/mvc-rc1/</link>
		<comments>http://www.primedigit.com/2009/01/28/mvc-rc1/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 18:05:05 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2009/01/28/mvc-rc1/</guid>
		<description><![CDATA[As I&#8217;m sure you noticed, MVC RC1 is out now. In reading through the release notes I found this: &#8220;The overloads for DropDownList and ListBox helper methods were reworked to fix various usability problems that were reported by customers.&#8221; Thanks for listening!]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m sure you noticed, <a href="http://haacked.com/archive/2009/01/27/aspnetmvc-release-candidate.aspx">MVC RC1</a> is out now. In reading through the release notes I found this:</p>
<blockquote><p><em>&#8220;The overloads for DropDownList and ListBox helper methods were reworked to fix various usability problems that were reported by customers.&#8221;</em></p></blockquote>
<p><a href="http://www.primedigit.com/2008/12/10/headaches-with-aspmvc-ui-helpers/">Thanks for listening!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2009/01/28/mvc-rc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GAC Conflicts with ASP MVC</title>
		<link>http://www.primedigit.com/2008/12/24/gac-conflicts-with-asp-mvc/</link>
		<comments>http://www.primedigit.com/2008/12/24/gac-conflicts-with-asp-mvc/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 17:04:58 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2008/12/24/gac-conflicts-with-asp-mvc/</guid>
		<description><![CDATA[By some strange combination of beta and pre-release candidate installs I managed to create some serious conflicts with ASP.NET MVC. Thereby producing this wonderful little error: Compiler Error Message: CS0433: The type 'System.Web.Mvc.FormMethod' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Mvc\1.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\06c0b3cf\32bec25d\assembly\dl3\71bfb65b\e11bf5c5_9e55c901\System.Web.Mvc.DLL' I am using my own build of the source from codeplex so that I [...]]]></description>
			<content:encoded><![CDATA[<p>By some strange combination of beta and pre-release candidate installs I managed to create some serious conflicts with ASP.NET MVC. Thereby producing this wonderful little error:</p>
<p><code>Compiler Error Message: CS0433: The type 'System.Web.Mvc.FormMethod' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Mvc\1.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\06c0b3cf\32bec25d\assembly\dl3\71bfb65b\e11bf5c5_9e55c901\System.Web.Mvc.DLL'</code></p>
<p>I am using my own build of the source from codeplex so that I can debug through it to improve my knowledge of the codebase. From research online it looks like the assembly version between the latest pre-release and the beta weren&#8217;t incremented, or the web-runner tries to look in the GAC before the /bin, or the evil garden gnomes are at it again, or Microsoft wants to punish me for building THEIR dll files.</p>
<p>To solve this problem, i opened up the AssemblyInfo.cs files of the Mvc project and upped the AssemblyVersion to 1.0.0.9. Then hacked my web config to use that version. As I&#8217;m running in debug mode, and can&#8217;t sign the assembly I also had to remove the PublicKeyToken from the reference.</p>
<p><code>&lt;add assembly="System.Web.Mvc, Version=1.0.0.9, Culture=neutral"/&gt;</code></p>
<p>And suddenly we&#8217;re back in business.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2008/12/24/gac-conflicts-with-asp-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ModelStateDictionary and ParameterBinding</title>
		<link>http://www.primedigit.com/2008/09/09/modelstatedictionary-and-parameterbinding/</link>
		<comments>http://www.primedigit.com/2008/09/09/modelstatedictionary-and-parameterbinding/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 18:14:38 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2008/09/09/modelstatedictionary-and-parameterbinding/</guid>
		<description><![CDATA[I laid this out in more detail on the forums here: http://forums.asp.net/p/1317154/2610342.aspx#2610342 I thought I&#8217;d mention it to this group so that people were aware of this difference between the interaction the old ParameterBinders and Rescues in version 4 and the new ModelBinders and HandleErrorAttributes of version 5. The new way of doing parameter binding [...]]]></description>
			<content:encoded><![CDATA[<p>I laid this out in more detail on the forums here:<br />
<a href="http://forums.asp.net/p/1317154/2610342.aspx#2610342">http://forums.asp.net/p/1317154/2610342.aspx#2610342</a></p>
<p>I thought I&#8217;d mention it to this group so that people were aware of this difference between the interaction the old ParameterBinders and Rescues in version 4 and the new ModelBinders and HandleErrorAttributes of version 5.</p>
<p>The new way of doing parameter binding expects all errors to be placed into the ModelStateDictionary specified in the GetValue method.<br />
public override object GetValue(ControllerContext controllerContext, string modelName, Type modelType, ModelStateDictionary modelState) {</p>
<p>The ModelStateDictionary can then be checked in the controller for errors via ViewData.ModelState.IsValid</p>
<p>I think the idea is that multiple binding errors can then be reported to the user at one time:<br />
foreach (var value in ViewData.ModelState.Values)<br />
{<br />
 value.Errors&#8230;..<br />
}</p>
<p>Unfortunatly our current NameValueDeserializer that is used by the DeserializeAttribute throws exceptions when it encounters errors. These exceptions are NOT caught by Rescues / HandleErrorAttributes. The ControllerActionInvoker (in preview 5) calls</p>
<p>IDictionary<string, object> parameters = GetParameterValues(methodInfo);</p>
<p>before the try/catch block that passes off errors to the HandleErrorAttributes. So if you&#8217;re using any kind of attribute deserialization and expecting your exceptions to be displayed all pretty like in your rescues&#8230; then move line #177 to line #180 of your ControllerActionInvoker.cs :)</p>
<p> -Will</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2008/09/09/modelstatedictionary-and-parameterbinding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing Framework for MS MVC.NET</title>
		<link>http://www.primedigit.com/2008/02/07/unit-testing-framework-for-ms-mvcnet/</link>
		<comments>http://www.primedigit.com/2008/02/07/unit-testing-framework-for-ms-mvcnet/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 06:04:43 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2008/02/07/unit-testing-framework-for-ms-mvcnet/</guid>
		<description><![CDATA[The Pain &#8211; A Brief History of MVC.NET Files: MvcTestingFramework.rar &#8211; or &#8211; MvcTestingFramework.zip Back in November, ScottGu gave us some great examples on how to use the (then unreleased) MVC Framework. A major advantage of this framework is to be in the ease of testing. One of the classes used in that demo was [...]]]></description>
			<content:encoded><![CDATA[<h3>The Pain &#8211; A Brief History of MVC.NET</h3>
<p><b>Files:</b> <a href="/content/MvcTestingFramework.rar">MvcTestingFramework.rar</a> &#8211; or &#8211; <a href="/content/MvcTestingFramework.zip">MvcTestingFramework.zip</a></p>
<p>Back in November, ScottGu gave us some great examples on how to use the (then unreleased) MVC Framework. A major advantage of this framework is to be in the ease of testing. One of the classes used in that demo was a <code>TestViewEngine</code> that was implemented to determine what variables were passed to <code>RenderView</code> and <code>RedirectToAction</code>.</p>
<p>
Since then we&#8217;ve <a href="http://forums.asp.net/t/1192080.aspx">learned</a> that it was some private class that wasn&#8217;t in the framework. In December, Phil Hack <a href="http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx">recommended subclassing</a> as a means to get at the <code>RenderView</code> which he admits leaves a certain bad taste in some people&#8217;s mouths.
</p>
<p>I&#8217;m one of those people.</p>
<p>He also went on to explain that it can be done through mocking with <a href="http://www.ayende.com/projects/rhino-mocks.aspx">RhinoMocks</a> but then changed his mind saying that it wouldn&#8217;t build against the actual CTP version of the framework. (Thanks, you tease.) Then there was the concept of <a href="http://haacked.com/archive/2007/11/05/rhino-mocks-extension-methods-mvc-crazy-delicious.aspx">putting it in an extension method</a>, but that prevents us from properly setting the stage for our tests.</p>
<p>There is also an issue with testing <code>TempData</code> in controllers even if you manage to get around the <code>RenderView</code> problems via subclassing. Ben Scheirman recommended doing this <a href="http://www.flux88.com/CommentView,guid,090db7e2-7462-4de2-bafa-ed005eccaed8.aspx">through mocking</a> using <code>SetupResult</code>. Justice Gray then chimes in that something similar can be done for <a href="http://graysmatter.codivation.com/CommentView,guid,be5350d5-ae5e-4702-8395-a31ee1f6ceee.aspx">mocking <code>Request.Form</code></a>.</p>
<p>Seeing all this chaos, and knowing that there had to be a better way, I&#8217;ve combined a number of these recommendations into a framework that allows for easy and effective testing of <code>ControllerAction</code>s.</p>
<p> It uses a bunch of Mocking, Reflection, and Dynamic Proxies to get the job done.</p>
<h3>Sample Uses of the Framework</h3>
<p>If you&#8217;re like me you&#8217;ve already downloaded the rar file at the top of the page. Please direct your attention to the MvcTestingFramework.Sample.Test project in the StarsControllerTest.cs file. Here&#8217;s you&#8217;ll find some simple uses of the framework.</p>
<h4>Using RenderView</h4>
<pre>
<code>
<div class="cf">
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span class="cb1">Test</span>]
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">public</span> <span class="cb2">void</span> ListControllerSelectsListView()
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">MvcTestHandler</span> handler = <span class="cb2">new</span> <span class="cb1">MvcTestHandler</span>();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">StarsController</span> controller = handler.CreateController&lt;<span class="cb1">StarsController</span>&gt;();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; controller.List();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">Assert</span>.AreEqual(<span class="cb3">"List"</span>, handler.RenderViewData.ViewName);
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>

</code>
</pre>
<p>
Note that we&#8217;re creating an instance of <code>MvcTestHandler</code> in this and every other test case in this class. This handler performs several functions, namely creating our <code>Controllers</code> and populating them correctly. We&#8217;re also able to get at the parameters used in the RenderView method call by our ControllerAction via the RenderViewData class.
</p>
<h4>Using Redirect To Action</h4>
<pre>
<code>
<div class="cf">
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span class="cb1">Test</span>]
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">public</span> <span class="cb2">void</span> AddFormStarShouldRedirectToList()
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">MvcTestHandler</span> handler = <span class="cb2">new</span> <span class="cb1">MvcTestHandler</span>();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">StarsController</span> controller = handler.CreateController&lt;<span class="cb1">StarsController</span>&gt;();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; controller.AddFormStar();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">Assert</span>.AreEqual(<span class="cb3">"List"</span>, handler.RedirectToActionData.ActionName);
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>

</code>
</pre>
<p>Again, we&#8217;re able to access the ActionName from the handler&#8217;s RedirectToActionData class.</p>
<h4>Using Request.Form and TempData</h4>
<pre>
<code>
<div class="cf">
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span class="cb1">Test</span>]
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">public</span> <span class="cb2">void</span> AddFormStarShouldSaveFormToTempData()
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">MvcTestHandler</span> handler = <span class="cb2">new</span> <span class="cb1">MvcTestHandler</span>();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">StarsController</span> controller = handler.CreateController&lt;<span class="cb1">StarsController</span>&gt;();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; handler.Form[<span class="cb3">"NewStarName"</span>] = <span class="cb3">"alpha c"</span>;
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; controller.AddFormStar();
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb1">Assert</span>.AreEqual(<span class="cb3">"alpha c"</span>, controller.TempData[<span class="cb3">"NewStarName"</span>]);
<p class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>

</code>
</pre>
<p>We simulate a form request, then read it back in from the controller&#8217;s TempData member. Do that with a controller that you make via a standard constructor and you won&#8217;t have such good results.</p>
<h3>Comments on this Framework</h3>
<p>The MvcTestingFramework relies on two great frameworks, the <a href="http://www.castleproject.org/dynamicproxy/index.html">Castle DynamicProxy</a> framework and the aforementioned RhinoMocks framework. </p>
<p>After establishing a proxy of the given controller, the existing <code>RedirectToAction</code> and <code>RenderView</code> methods are changed so that they save the parameters and don&#8217;t actually redirect or render a view. </p>
<p>One particular annoying part (and there were several, saved only by <a href="http://www.aisto.com/roeder/dotnet/">The Reflector</a>) was that a couple of objects types used by <code>RedirectToAction</code> are marked as <code>internal</code>, so I was forced to iterate over the properties looking for the Action and Controller properties. MS&#8230; Please, no more <a href="http://graysmatter.codivation.com/CommentView,guid,be5350d5-ae5e-4702-8395-a31ee1f6ceee.aspx">hoops and lions</a>.</p>
<p>The one area that I don&#8217;t have working is Session variables. (You&#8217;ll note those unit tests fail.) Hopefully someone more familiar with Rhino Mocks will be able to get this working.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2008/02/07/unit-testing-framework-for-ms-mvcnet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>LINQ EndsWith</title>
		<link>http://www.primedigit.com/2007/12/11/linq-endswith/</link>
		<comments>http://www.primedigit.com/2007/12/11/linq-endswith/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 17:39:24 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2007/12/11/linq-endswith/</guid>
		<description><![CDATA[From the bottom of the Entity Framework Beta 3 docs on Query Execution, &#8220;The EndsWith method can also return different results because SQL Server considers two strings to be equal if they only differ in trailing white space, whereas the CLR considers them to be not equal.&#8221; That&#8217;s not exactly clear, so I spent some [...]]]></description>
			<content:encoded><![CDATA[<p>From the bottom of the Entity Framework Beta 3 docs on <a href="http://msdn2.microsoft.com/en-us/library/bb738633(VS.90).aspx">Query Execution</a>, &#8220;The <em>EndsWith</em> method can also return different results because SQL Server considers two strings to be equal if they only differ in trailing white space, whereas the CLR considers them to be not equal.&#8221; That&#8217;s not exactly clear, so I spent some time trying out different scenarios.</p>
<h3>Case One:</h3>
<p>Database Field ColorName : &#8216;Blue&nbsp;&nbsp;&nbsp;&#8217; // 3 spaces</p>
<p>SQL Query: &#8230; WHERE ColorName LIKE &#8216;%e&nbsp;&nbsp;&nbsp;&#8217;<br />
Returns 1<br />
SQL Query: &#8230; WHERE ColorName LIKE &#8216;%e&#8217;<br />
Returns 0<br />
SQL Query: &#8230; WHERE ColorName = &#8216;blue&#8217;<br />
<strong>Returns 1</strong><br />
SQL Query: &#8230; WHERE ColorName = &#8216;blue&nbsp;&nbsp;&nbsp;&#8217;<br />
Returns 1</p>
<p>LINQ Query &#8230; where c.ColorName.EndsWith(&#8216;e&#8217;) select c;<br />
Returns 0<br />
LINQ Query &#8230; where c.ColorName.EndsWith(&#8216;e&nbsp;&nbsp;&nbsp;&#8217;) select c;<br />
<strong>Returns 0</strong><br />
LINQ Query &#8230; where c.ColorName.EndsWith(&#8216;&nbsp;&#8217;) select c;<br />
Returns 1<br />
LINQ Query &#8230; where c.ColorName.Trim().EndsWith(&#8216;e&#8217;) select c;<br />
Returns 1<br />
LINQ Query &#8230; where c.ColorName.Trim().EndsWith(&#8216;e&nbsp;&nbsp;&nbsp;&#8217;) select c;<br />
<strong>Returns 1</strong></p>
<h3>Case Two:</h3>
<p>Database Field ColorName : &#8216;Blue&#8217;</p>
<p>SQL Query: &#8230; WHERE ColorName LIKE &#8216;%e&nbsp;&nbsp;&nbsp;&#8217;<br />
Returns 0<br />
SQL Query: &#8230; WHERE ColorName LIKE &#8216;%e&#8217;<br />
Returns 1<br />
SQL Query: &#8230; WHERE ColorName = &#8216;blue&#8217;<br />
Returns 1<br />
SQL Query: &#8230; WHERE ColorName = &#8216;blue&nbsp;&nbsp;&nbsp;&#8217;<br />
<strong>Returns 1</strong></p>
<p>LINQ Query &#8230; where c.ColorName.EndsWith(&#8216;e&#8217;) select c;<br />
Returns 1<br />
LINQ Query &#8230; where c.ColorName.EndsWith(&#8216;e&nbsp;&nbsp;&nbsp;&#8217;) select c;<br />
<strong>Returns 1</strong><br />
LINQ Query &#8230; where c.ColorName.EndsWith(&#8216; &#8216;) select c;<br />
<strong>Returns 1</strong><br />
LINQ Query &#8230; where c.ColorName.Trim().EndsWith(&#8216;e&#8217;) select c;<br />
Returns 1<br />
LINQ Query &#8230; where c.ColorName.Trim().EndsWith(&#8216;e&nbsp;&nbsp;&nbsp;&#8217;) select c;<br />
<strong>Returns 1</strong></p>
<p>So basically if you want to find a string that actually ends with a &#8216;&nbsp;&#8217; using LINQ to Entities, best to use something other than EndsWith. This is certain to cause some major headaches for someone, so hopefully it gets fixed before the EF is out of beta.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2007/12/11/linq-endswith/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Designer CTP2 Comments</title>
		<link>http://www.primedigit.com/2007/12/07/entity-designer-ctp2-comments/</link>
		<comments>http://www.primedigit.com/2007/12/07/entity-designer-ctp2-comments/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 19:37:19 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://www.primedigit.com/2007/12/07/entity-designer-ctp2-comments/</guid>
		<description><![CDATA[I&#8217;ve spent some time yesterday and today playing around with the new Entity Designer GUI and Framework. So far I&#8217;m impressed with the possibilities and bothered by simple things that could cause repetitive headaches. Here are a few suggestions that I&#8217;d offer to the Entity Designer team: Ignore the sysdiagrams table when importing by default. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some time yesterday and today playing around with the new <a href="http://blogs.msdn.com/adonet/archive/2007/12/06/entity-designer-ctp2.aspx">Entity Designer</a> GUI and Framework. So far I&#8217;m impressed with the possibilities and bothered by simple things that could cause repetitive headaches. Here are a few suggestions that I&#8217;d offer to the Entity Designer team:</p>
<ul>
<li>Ignore the sysdiagrams table when importing by default. Those of us who actually want this can check this box when we import the tables. SQL2005 is kind enough to hide it in the System Tables folder, please do something similar.</li>
<li>How do I view the XML code? The only time I can easily get access to it is when there is an error. I can’t view it by right clicking on the .edmx file. (Like one can with a Data Access Layer .xsd file.) </li>
<li>Return types of Navigation Properties are not displayed at all in the designer and difficult to ascertain without plowing through generated code.</li>
<li>Foreign key naming conventions are completely ignored for imported tables. Please don&#8217;t ignore them, or make it easier to see what they were.</li>
</ul>
<p>To illustrate points three and four above, I&#8217;ve made myself a very simple database which might represent maternal genealogies, perhaps for someone studying <a href="http://en.wikipedia.org/wiki/Mitochondrial_DNA">Mitochondrial DNA</a>. </p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/databasedesign.png" /></p>
<p>As you can see, each person has a foreign key to another person who happens to be that person&#8217;s mother. Importing this into the Entity Designer via the wizard gives us two very cryptic columns called Person1 and Person2. Conceptually we might understand that each person has both a reference to her mother as well as a reference to all of her daughters. So one of these keys is a singular reference that we&#8217;d like to rename to &#8220;Mother&#8221; and another that we&#8217;d like to rename to &#8220;Children&#8221;. Examining these Navigation Properties in the designer shows:</p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/person1.png" /><br />
<strong>Person 1</strong></p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/person2.png" /><br />
<strong>Person 2</strong></p>
<p>Both of them have public getters and setters, both use the same Association, and neither of them list what type they return. To figure how to rename these, we must go to the generated c# code. (We can&#8217;t get to the xml code easily after all.) </p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/sourcecode.png"  /></p>
<p>So we can see from here that Person1 should be our Children/Daughters and Person2 should be Mother. Now we can rename these links appropriately.</p>
<hr />
<p>Taking a look at a different example will illustrate my comment about ignoring foreign key names. This database is very simple with two tables as follows.</p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/machine_operatorsdb.png" /></p>
<p>Importing this into the Entity Designer shows:</p>
<p><img src="http://www.primedigit.com/wp-content/uploads/2007/12/designer_machines_operators.png" /></p>
<p>Now this is a bit easier than the previous problem to fix as the designer shows that the Association is liked to either &#8220;LastBrokenBy&#8221; or &#8220;LastFixedBy&#8221;. Is fixing all of these names part of the expected standard process of setting up the Entity Design?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.primedigit.com/2007/12/07/entity-designer-ctp2-comments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
