<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Martijn Boland</title>
	
	<link>http://blogs.taiga.nl/martijn</link>
	<description>New adventures in .NET</description>
	<lastBuildDate>Tue, 27 Apr 2010 20:51:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/martijnboland" /><feedburner:info uri="martijnboland" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Entity Framework 4 Code-First demo updated to Feature CTP3</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/8eb2e5NDPJQ/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:51:13 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[O/R mapping]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/</guid>
		<description><![CDATA[The EF 4 code-first demo has been updated to reference the EF4 Feature CTP3 dll at its default location. To run the demo, you have to make sure that the you have it installed. Download the EF 4 Feature CTP3 at http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&#38;displayLang=en. Although the demo was originally developed with VS 2010 Beta 2 everything works [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/">EF 4 code-first demo</a> has been updated to reference the EF4 Feature CTP3 dll at its default location. To run the demo, you have to make sure that the you have it installed. Download the EF 4 Feature CTP3 at <a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=af18e652-9ea7-478b-8b41-8424b94e3f58&amp;displayLang=en</a>.</p>
<p>Although the demo was originally developed with VS 2010 Beta 2 everything works perfectly fine on VS 2010 RTM.</p>
<p>You can find the demo sources at github: <a title="http://github.com/martijnboland/EF4-codeonly-demo" href="http://github.com/martijnboland/EF4-codeonly-demo">http://github.com/martijnboland/EF4-codeonly-demo</a> where it’s also possible to download the sources all at once.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=8eb2e5NDPJQ:kJbHhaOrPaM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=8eb2e5NDPJQ:kJbHhaOrPaM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=8eb2e5NDPJQ:kJbHhaOrPaM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=8eb2e5NDPJQ:kJbHhaOrPaM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/8eb2e5NDPJQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2010/04/27/entity-framework-4-code-first-demo-updated-to-feature-ctp3/</feedburner:origLink></item>
		<item>
		<title>Staying out of .NET Open Source dependency hell</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/MM9Wwh1c5rc/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/04/14/staying-out-of-net-open-source-dependency-hell/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 16:01:13 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/04/14/staying-out-of-net-open-source-dependency-hell/</guid>
		<description><![CDATA[Probably all consumers of Open Source .NET libraries have run into the following situation: you’re using specific versions of library X and library Y in your application but library X also uses library Y, but a different incompatible version. Aaarrrghh!!! A classic example of Dependency Hell. There are technical solutions out there that address this [...]]]></description>
			<content:encoded><![CDATA[<p>Probably all consumers of Open Source .NET libraries have run into the following situation: you’re using specific versions of library X and library Y in your application but library X also uses library Y, but a different incompatible version. Aaarrrghh!!!</p>
<p>A classic example of <a href="http://en.wikipedia.org/wiki/Dependency_hell">Dependency Hell</a>.</p>
<p>There are technical solutions out there that address this issue such as <a href="http://hornget.net">Horn</a> or <a href="http://maven.apache.org/">Maven</a> for Java, but I think there is an alternative non-technical solution: Just reduce the amount of libraries that you depend on. </p>
<p>This might sound silly because why re-invent the wheel? Well, you don’t have to. Let’s take a concrete example. I was using <a href="http://mvccontrib.codeplex.com">MvcContrib’s</a>&#160;<a href="http://www.castleproject.org/container/">Castle Windsor</a> controller factory in a project, but then, when I upgraded Castle Windsor it didn’t work anymore. Of course there wasn’t a new version of MvcContrib released yet that depended on the new Castle Windsor, so I had to build a new version from source. Then I started looking at the code and realized that it was just one simple class from the library that I was using. So I <strike>created</strike> <em>copy &amp; pasted</em> a Windsor Controller factory class in my own project and got rid of one external dependency. Yes, I’m promoting Copy &amp; Paste development here!</p>
<p>Of course, I’m not advocating that you should get rid of all your dependencies, but it might be wise to have a look at the dependencies and evaluate if you can get without some of them with just a little bit of work. This can save you from a lot of trouble, especially when you’re the type of programmer like me that wants to run the latest and greatest version of everything but <em>not </em>wants to build everything from source over and over again.</p>
<p>What works for me is the following guideline: try to keep away from libraries that use other (non-Microsoft base class) libraries if there are reasonable alternatives.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=MM9Wwh1c5rc:6GQwSsNKtzM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=MM9Wwh1c5rc:6GQwSsNKtzM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=MM9Wwh1c5rc:6GQwSsNKtzM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=MM9Wwh1c5rc:6GQwSsNKtzM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/MM9Wwh1c5rc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/04/14/staying-out-of-net-open-source-dependency-hell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2010/04/14/staying-out-of-net-open-source-dependency-hell/</feedburner:origLink></item>
		<item>
		<title>The risks of learning a SharePoint alternative</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/ty5_qvEe-k4/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/02/03/the-risks-of-learning-a-sharepoint-alternative/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:45:06 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[CMS]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/02/03/the-risks-of-learning-a-sharepoint-alternative/</guid>
		<description><![CDATA[A few days ago, I heard someone complaining about the risk of introducing a light-weight CMS as an alternative for the default SharePoint (MOSS2007) solutions. The main issue was the amount of learning that would be required to get productive in the alternative environment. Now let me throw in a bold statement: if your developers [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago, I heard someone complaining about the risk of introducing a light-weight CMS as an alternative for the default SharePoint (MOSS2007) solutions. The main issue was the amount of learning that would be required to get productive in the alternative environment.</p>
<p>Now let me throw in a bold statement: if your developers have managed to handle the complexity of a SharePoint solution, they can easily learn an alternative. The only risk is that they don’t want to go back <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=ty5_qvEe-k4:XExM90gZuw4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=ty5_qvEe-k4:XExM90gZuw4:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=ty5_qvEe-k4:XExM90gZuw4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=ty5_qvEe-k4:XExM90gZuw4:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/ty5_qvEe-k4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/02/03/the-risks-of-learning-a-sharepoint-alternative/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2010/02/03/the-risks-of-learning-a-sharepoint-alternative/</feedburner:origLink></item>
		<item>
		<title>Paging demo for ASP.NET MVC 2</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/O3kKdel-t3k/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:27:58 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Area]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</guid>
		<description><![CDATA[During work, I discovered that the pager that I created a while ago didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created [...]]]></description>
			<content:encoded><![CDATA[<p>During work, I discovered that the <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/" target="_blank">pager that I created a while ago</a> didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created an GetVirtualPathForArea() extension method on RouteCollection. Calling this one, instead of GetVirtualPath() made things work properly in area’s.</p>
<p>You can get the code for ASP.NET MVC 2 at <a title="http://github.com/martijnboland/MvcPaging/tree/mvc2" href="http://github.com/martijnboland/MvcPaging/tree/mvc2">http://github.com/martijnboland/MvcPaging/tree/mvc2</a> (mvc2 branch of the MvcPaging repository).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=O3kKdel-t3k:9om1y6G07CM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=O3kKdel-t3k:9om1y6G07CM:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=O3kKdel-t3k:9om1y6G07CM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=O3kKdel-t3k:9om1y6G07CM:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/O3kKdel-t3k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</feedburner:origLink></item>
		<item>
		<title>Cuyahoga 2.0 Alpha released</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/NitRvDAa3_c/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:32:51 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[Cuyahoga]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/</guid>
		<description><![CDATA[Just a little post to let you know that I released the first Alpha of the next generation of the Cuyahoga CMS yesterday. For the people who don’t know Cuyahoga: it’s a .NET CMS that uses lots of Open Source components like NHibernate, Castle Windsor and Lucene.NET. Although not as polished as Umbraco or Dotnetnuke, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little post to let you know that I released the first Alpha of the next generation of the <a href="http://cuyahoga-project.org">Cuyahoga</a> CMS yesterday. For the people who don’t know Cuyahoga: it’s a .NET CMS that uses lots of Open Source components like NHibernate, Castle Windsor and Lucene.NET. Although not as polished as <a href="http://umbraco.org" target="_blank">Umbraco</a> or <a href="http://www.dotnetnuke.com" target="_blank">Dotnetnuke</a>, I think it still shines when doing custom module and template development.</p>
<p>Development has been a long journey. Already back in 2006 we started development for the 2.0 version. In that time most of the work was done by Max Gaerber. He did a fantastic job in the design of the generic handling of content items.</p>
<p>Then somewhere in 2007 we started the new admin with Castle Monorail, did a spike with the first ASP.NET MVC, changed back to Monorail and finally changed to ASP.NET MVC again. The switch from ASP.NET WebForms to MVC for the site admin allowed us to do some pretty advanced AJAX stuff. The result is still a little rough around the edges, but it’s usable for experimental purposes. </p>
<p>Download it at <a title="http://sourceforge.net/projects/cuyahoga/files/" href="http://sourceforge.net/projects/cuyahoga/files/">http://sourceforge.net/projects/cuyahoga/files/</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=NitRvDAa3_c:JDNAdtepZRs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=NitRvDAa3_c:JDNAdtepZRs:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=NitRvDAa3_c:JDNAdtepZRs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=NitRvDAa3_c:JDNAdtepZRs:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/NitRvDAa3_c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/12/12/cuyahoga-2-0-alpha-released/</feedburner:origLink></item>
		<item>
		<title>Entity Framework 4.0: a fresh start (with demo application)</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/0V1JVeV9reU/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 21:31:42 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[O/R mapping]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/</guid>
		<description><![CDATA[Edited 2009-11-26: removed EF4 Feature CTP from demo package and added some code examples. So, Entity Framework 1.0 pretty much sucks (compared to alternatives), but I’m glad to see that things have improved a lot in version 4.0 (we’ll call that EF4 from now). To see how the improvements work out, I did a quick [...]]]></description>
			<content:encoded><![CDATA[<p>Edited 2009-11-26: removed EF4 Feature CTP from demo package and added some code examples.</p>
<p>So, <a href="http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/">Entity Framework 1.0 pretty much sucks</a> (compared to alternatives), but I’m glad to see that things have improved a lot in version 4.0 (we’ll call that EF4 from now). To see how the improvements work out, I did a quick <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/EF4Demo.zip" target="_blank">spike</a> that also gave me the opportunity to test some new ASP.NET MVC 2 features that I might blog about later.</p>
<h3>What’s in it?</h3>
<ul>
<li>Entity Framework 4 with POCO entity objects and <a href="http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx" target="_blank">code-only configuration</a> (no edmx);</li>
<li>Data access abstracted via repository interfaces;</li>
<li>ASP.NET 2 MVC for the UI;</li>
<li>Validation with Data Annotations;</li>
<li>Castle Windsor IoC container to wire the various components together;</li>
</ul>
<h3>EF4 POCO</h3>
<p>In EF4, it’s now possible to use entity classes that don’t have to inherit from EntityObject. This allows for better testability and separation of concerns. This is how an entity looks in the demo:</p>
<pre class="brush: csharp;">public class Course
{
    public virtual int Id { get; set; }

    [Required(ErrorMessage="Course title is required")]
    public virtual string Title { get; set; }

    [Required(ErrorMessage = "Price is required")]
    [DataType(DataType.Currency)]
    [Range(10.00, double.MaxValue, ErrorMessage="The minimum price is {1}")]
    public virtual decimal Price { get; set; }

    public virtual ISet&lt;Schedule&gt; Schedules { get; set; }

    public Course()
    {
        this.Schedules = new HashSet&lt;Schedule&gt;();
    }
}</pre>
<p>Note that all properties are marked virtual. This allows EF4 to do some magic with run-time proxy generation to allow lazy loading and change notification.</p>
<p>Also note that we can now easily add validation attributes (in this case from Sytem.ComponentModel.DataAnnotations). We don’t have to use those <a href="http://ayende.com/Blog/archive/2009/05/04/the-buddy-classes-are-drowning-dry.aspx" target="_blank">dreadful ‘buddy classes’</a> anymore to hold the meta-data.</p>
<h3>Code-only configuration</h3>
<p>EF4 now allows model-first design from the VS 2010 designer, but it can still get awkward with a lot of entities. Fortunately, the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=13fdfce4-7f92-438f-8058-b5b4041d0f01" target="_blank">EF4 Feature CTP</a> makes it possible <a href="http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx" target="_blank">to do everything in code</a>.</p>
<p>So you now just create your POCO entity and add a mapping class that replaces the edmx designer:</p>
<pre class="brush: csharp;">public class CourseMapping : EntityConfiguration&lt;Course&gt;
{
    public CourseMapping()
    {
        HasKey(c =&gt; c.Id);
        Property(c =&gt; c.Id).IsIdentity();
        MapSingleType(c =&gt; new
        {
            courseid = c.Id,
            title = c.Title,
            price = c.Price
        }).ToTable("course");
        Property(c =&gt; c.Price).HasStoreType("money").HasPrecision(19, 4);
    }
}</pre>
<p>Looks remarkably similar to <a href="http://wiki.fluentnhibernate.org/Main_Page" target="_blank">Fluent NHibernate</a>, doesn’t it? <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I’m not sure if this is the most optimal way to define the mapping, but it works. In the demo, there is a class CoursesContextBuilder that wraps the ContextBuilder from the EF4 Feature CTP where the mappings are added. It also serves as a factory for new ObjectContext instances () :</p>
<pre class="brush: csharp;">public class CoursesContextBuilder
{
    private ContextBuilder&lt;ObjectContext&gt; _builder;
    private string _defaultConnectionString;

    public CoursesContextBuilder(string defaultConnectionString)
    {
        this._defaultConnectionString = defaultConnectionString;
        this._builder = new ContextBuilder&lt;ObjectContext&gt;();
        ConfigureMappings();
    }

    private void ConfigureMappings()
    {
        _builder.Configurations.Add(new TeacherMapping());
        _builder.Configurations.Add(new CourseMapping());
        _builder.Configurations.Add(new ScheduleMapping());
    }

    public ObjectContext GetContext()
    {
        return GetContext(_defaultConnectionString);
    }

    public ObjectContext GetContext(string connectionString)
    {
        var context = _builder.Create(GetConnection(connectionString));
        context.ContextOptions.LazyLoadingEnabled = true;
        return context;
    }

    private DbConnection GetConnection(string connectionString)
    {
        // Hardcoded to SqlConnection for this demo.
        return new SqlConnection(connectionString);
    }
}</pre>
<p>That’s all we need to get EF4 working. In theory, we can now do everything with the POCO classes and the ObjectContext that comes from the CoursesContextBuilder, but of course if we would use it this way, we are directly tied to EF again and there goes away our testability.</p>
<h3>Repository implementation</h3>
<p>To make sure our application code isn’t tied to EF directly, data access goes through Repository interfaces. In the demo app you can find a generic IRepository&lt;T&gt; interface that is implemented by an EfRepository&lt;T&gt; class. The EfRepository implementation uses the EF ObjectContext to perform queries and so on. Note that we added an extra IContextManager interface that the EfRepository depends on. The IContextManager is responsible for managing the lifetime of the ObjectContext that is obtained from the ContextBuilder. This way, the repository implementations don’t have to worry about creating and disposing ObjectContext instances. It’s just always always available.All specific Repository interfaces inherit from IRepository&lt;T&gt; and the specific implementations inherit from EfRepository&lt;T&gt;.</p>
<pre class="brush: csharp;">public interface ICourseRepository : IRepository&lt;Course&gt;
{
    void DeleteCourseWithSchedule(Course course);
    Ef4Poco.Domain.Course GetCourseWithSchedulesAndTeachers(int courseId);
    void RemoveScheduleFromCourse(Schedule schedule, Course course);
}</pre>
<pre class="brush: csharp;">/// &lt;summary&gt;
/// Course-specific repository.
/// &lt;/summary&gt;
public class CourseRepository : EfRepository&lt;Course&gt;, ICourseRepository
{
    public CourseRepository(IContextManager contextManager)
        : base(contextManager)
    { }

    public Course GetCourseWithSchedulesAndTeachers(int courseId)
    {
        // Wouldn't it be nice to have strong-typed includes?
        var query = from c in ObjectSet.Include("Schedules").Include("Schedules.Teacher")
                    where c.Id == courseId
                    select c;
        return query.Single();
    }

    public void RemoveScheduleFromCourse(Schedule schedule, Course course)
    {
        course.Schedules.Remove(schedule);
        CurrentObjectContext.DeleteObject(schedule);
        CurrentObjectContext.SaveChanges();
    }

    public void DeleteCourseWithSchedule(Course course)
    {
        // Howto configure cascade delete via code? This is a little cumbersome.
        var schedules = new List&lt;Schedule&gt;(course.Schedules);
        foreach (var schedule in schedules)
        {
            CurrentObjectContext.DeleteObject(schedule);
        }
        CurrentObjectContext.DeleteObject(course);
        CurrentObjectContext.SaveChanges();
    }
}</pre>
<h3>Consuming the data access interfaces</h3>
<p>Now we have our data access interfaces in place, it’s time for consuming. This is plain simple. Below is an example of how a controller in the ASP.NET MVC app in the demo uses the interfaces:</p>
<pre class="brush: csharp;">public class TeachersController : Controller
{
    private ITeacherRepository _teacherRepository;

    public TeachersController(ITeacherRepository teacherRepository)
    {
        _teacherRepository = teacherRepository;
    }

    public ActionResult Index()
    {
        var teachers = _teacherRepository.Find().OrderBy(t =&gt; t.Name);
        return View(teachers);
    }

    [...snip other methods]
}</pre>
<h3>The demo app</h3>
<p>You can<a href="http://blogs.taiga.nl/martijn/wp-content/uploads/EF4Demo.zip" target="_blank"> download the demo</a> to see what’s possible. It’s by no means a best practices example. Just a spike to test out various new technologies.</p>
<p>To run the demo, you’ll need Visual Studio 2010 Beta 2, <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=13fdfce4-7f92-438f-8058-b5b4041d0f01" target="_blank">the latest EF4 Feature CTP</a> and SQL Server (Express).</p>
<p>Both, the web and the test project have a connection string in the config file that defaults to the .\SQLEXPRESS instance. Change that if you want to use a different instance. The database name doesn’t matter because a new database will be created the first time you run the application. Note that the reference to the EF4 feature CTP (Microsoft.Data.Entity.CTP.dll) points to C:\Program Files (x86)\Microsoft ADO.NET Entity Framework Feature CTP2\Binaries. On 32 bit machines, you’ll probably have to change that to C:\Program Files\…</p>
<h3>Some observations</h3>
<ul>
<li>Entity Framework 4.0 is much, much better than version 1.0, especially for a model-first approach;</li>
<li>It’s not on par yet with <a href="http://nhforge.org" target="_blank">NHibernate</a> feature-wise (for example, I really miss cascade settings). Given the choice, I’d still opt for NHibernate, but it’s not a bad product anymore and I&#8217;d prefer it over LINQ to SQL at this time.</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=0V1JVeV9reU:9k0lhqK3SPI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=0V1JVeV9reU:9k0lhqK3SPI:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=0V1JVeV9reU:9k0lhqK3SPI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=0V1JVeV9reU:9k0lhqK3SPI:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/0V1JVeV9reU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/11/22/entity-framework-4-0-a-fresh-start-with-demo-application/</feedburner:origLink></item>
		<item>
		<title>Random observations from Øredev 2009</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/ppxAj_ru8tM/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/11/11/random-observations-from-redev-2009/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 12:23:36 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Oredev]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/11/11/random-observations-from-redev-2009/</guid>
		<description><![CDATA[Last week, my Taiga partner in crime Erwin and I went on a road trip to Malmö Sweden to visit the Øredev 2009 conference. All I can say is that it was the best conference I ever attended. Fantastic sessions, crowd and atmosphere! To summarize, some random observations: JAVA vs. .NET: from the .NET prespective, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, my Taiga partner in crime Erwin and I went on a road trip to Malmö Sweden to visit the <a href="http://www.oredev.org" target="_blank">Øredev</a> 2009 conference. All I can say is that it was the best conference I ever attended. Fantastic sessions, crowd and atmosphere!</p>
<p>To summarize, some random observations:</p>
<ul>
<li>JAVA vs. .NET: from the .NET prespective, I noticed that the JAVA crowd is way ahead of us in terms of agile development processes, but is starting to lag behind technology wise (still doing massive Spring configurations and generics appeared almost absent); </li>
<li><a href="http://en.wikipedia.org/wiki/NoSQL" target="_blank">NoSQL</a>: time will tell, but this could really change the way we think about structuring our data in the future. By far the session I attended that caused the most excitement in the crowd; </li>
<li>When asked how many people in the audience use NHibernate, more than 50% raised their hands! (ok, it was a session about the NHibernate ecosystem); </li>
<li>Entity Framework 4.0 really is going to be a big improvement; </li>
<li>ASP.NET WebForms 4.0 has some improvements, but nothing that got me really excited. It feels like WebForms is finished (as in proven technology that isn’t going to change much anymore); </li>
<li>Google returns totally different search results in Sweden <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=ppxAj_ru8tM:YFHgRCMifsg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=ppxAj_ru8tM:YFHgRCMifsg:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=ppxAj_ru8tM:YFHgRCMifsg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=ppxAj_ru8tM:YFHgRCMifsg:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/ppxAj_ru8tM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/11/11/random-observations-from-redev-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/11/11/random-observations-from-redev-2009/</feedburner:origLink></item>
		<item>
		<title>Are we out of touch?</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/zG5HhZvImA8/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/11/11/are-we-out-of-touch/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 11:33:18 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Improving]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Oredev]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/11/11/are-we-out-of-touch/</guid>
		<description><![CDATA[Last week at the Øredev 2009 conference in Malmö, there was a closing panel with various big names in software development. At one time during the discussion, Scott Hanselman brought up the issue that we (as in the people who attended the conference) might be out of touch with people like ‘The Chief Architect of [...]]]></description>
			<content:encoded><![CDATA[<p>Last week at the <a href="http://www.oredev.org" target="_blank">Øredev 2009 conference in Malmö</a>, there was a <a href="http://www.hanselman.com/blog/Oredev2009LIVENowRecordedClosingPanelVideo.aspx" target="_blank">closing panel with various big names in software development</a>. </p>
<p>At one time during the discussion, <a href="http://www.hanselman.com/blog/" target="_blank">Scott Hanselman</a> brought up the issue that <em>we</em> (as in the people who attended the conference) might be out of touch with people like ‘The Chief Architect of the Nebraska Forestry Department’, formerly know as ‘Mort’. The discussion continued a little with terms like ‘elitist geeks’ and so on and during the discussion I started to get the feeling that Scott might have a point here. Aren’t we out of touch with the majority of developers that do the ‘real’ work? </p>
<p>Then, <a href="http://ayende.com/Blog" target="_blank">Ayende</a> countered with a statement that he simply doesn’t trust developers who don’t keep up with technology, blogs and want to learn and made a perfect analogy: when you have to visit a doctor, do you trust one that doesn’t go to conferences and reads his literature to keep up to date? </p>
<p>That statement immediately did it for me. We aren’t out of touch at all. We are working in an industry where things change rapidly and I think it’s our obligation as professionals and towards our customers to continue to learn and improve ourselves. Maybe the people who don’t (want to) do this are the ones out of touch?</p>
<p>So you might think comparing a doctor with a software developer isn’t fair because the doctor is dealing with something much more important like the health of people and we developers just deal with computers and stuff? Think twice: our customers invest lots of money in software and for that amount of money they just expect us to stay current on technology.</p>
<p>Keep learning and improving! </p>
<p>(and call me an elitist geek if you like <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=zG5HhZvImA8:FJHxH7sAgAY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=zG5HhZvImA8:FJHxH7sAgAY:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=zG5HhZvImA8:FJHxH7sAgAY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=zG5HhZvImA8:FJHxH7sAgAY:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/zG5HhZvImA8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/11/11/are-we-out-of-touch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/11/11/are-we-out-of-touch/</feedburner:origLink></item>
		<item>
		<title>One year after the Entity Framework Vote of No Confidence…</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/71PW1P7Ql0I/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 15:52:07 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[O/R mapping]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/</guid>
		<description><![CDATA[About a year ago, a few people (called by some as ‘The NHibernate Mafia’) wrote a vote of no confidence against the Microsoft ADO.NET Entity Framework (EF), mainly because a big influential company like Microsoft was releasing an inferior tool set. See the text of the petition for the detailed reasoning. My initial thoughts were [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago, a few people (called by some as ‘The NHibernate Mafia’) wrote a <a href="http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/" target="_blank">vote of no confidence</a> against the Microsoft ADO.NET Entity Framework (EF), mainly because a big influential company like Microsoft was releasing an inferior tool set. See the <a href="http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/" target="_blank">text of the petition</a> for the detailed reasoning. </p>
<p>My initial thoughts were ‘why worry, there are plenty alternatives like <a href="http://nhforge.org" target="_blank">NHibernate</a>, <a href="http://www.llblgen.com" target="_blank">LLBLGen Pro</a> or <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank">LINQ to SQL</a>’ and although I agree with the content of the vote of no confidence, I decided not to sign. That was until realized that as a contractor, you often have to confirm to the technology that the customer has adopted, so it’s to be expected that a lot of future projects have EF as their O/R mapping layer because ‘Microsoft says it’s the way to do data access’. I signed and yes, it’s the selfish me that made me do it.</p>
<p>So now we’re one year later and I just started on a new contract where EF is being used and as I already feared one year ago things are not pretty. The previous developers seem to have struggled a lot, which resulted in poor performance and lots of workarounds.</p>
<p>And you know what: I don’t blame EF itself or the developers but only Microsoft marketing for labeling the Entity Framework as the ‘preferred magic way to do data access’ and all the surrounding blah of future products that will build on EF so people blindly take it as their weapon of choice.</p>
<p>Sorry for this somewhat negative post, but I had to write this off.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=71PW1P7Ql0I:lK2I3EuAgv8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=71PW1P7Ql0I:lK2I3EuAgv8:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=71PW1P7Ql0I:lK2I3EuAgv8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=71PW1P7Ql0I:lK2I3EuAgv8:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/71PW1P7Ql0I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/09/24/one-year-after-the-entity-framework-vote-of-no-confidence/</feedburner:origLink></item>
		<item>
		<title>Considering ASP.NET MVC UI controls? Learn HTML and Javascript!</title>
		<link>http://feedproxy.google.com/~r/martijnboland/~3/sPe315f0eRI/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 09:31:16 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[WebForms]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/</guid>
		<description><![CDATA[Warning: highly subjective content ahead. In the recent weeks we’ve seen several control vendors come up with toolkits that target ASP.NET MVC. Personally, I don’t see anything that might make me starting to consider picking one of these toolkits to speed up development. Why on earth would I prefer a wrapper around jQuery UI or [...]]]></description>
			<content:encoded><![CDATA[<p>Warning: highly subjective content ahead.</p>
<p>In the recent weeks we’ve seen <a href="http://www.telerik.com/products/aspnet-mvc.aspx" target="_blank">several</a> <a href="http://mvc.devexpress.com/" target="_blank">control</a> <a href="http://www.syncfusion.com/products/aspnet-mvc" target="_blank">vendors</a> come up with toolkits that target ASP.NET MVC. Personally, I don’t see anything that might make me starting to consider picking one of these toolkits to speed up development. Why on earth would I prefer a wrapper around jQuery UI or shoehorning existing WebForms controls in MVC views?</p>
<p>The beauty of ASP.NET MVC is that it embraces the web as it is and this automatically involves HTML, CSS and Javascript. Don’t be afraid for that. The combination can be so powerful! Why aren’t there any large component vendors for PHP, Rails, Django etc? Isn’t it probably possible that these components are not required to do proper web development?</p>
<p>The control vendors seem to be targeting people who come from a Windows background that don’t want to learn HTML and Javascript, but from my experiences I can say that those people should really stick to WebForms.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/martijnboland?a=sPe315f0eRI:HuvsYKeLbFA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=sPe315f0eRI:HuvsYKeLbFA:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/martijnboland?d=G79ilh31hkQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/martijnboland?a=sPe315f0eRI:HuvsYKeLbFA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/martijnboland?i=sPe315f0eRI:HuvsYKeLbFA:V_sGLiPBpWU" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/martijnboland/~4/sPe315f0eRI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://blogs.taiga.nl/martijn/2009/08/13/considering-asp-net-mvc-ui-controls-learn-html-and-javascript/</feedburner:origLink></item>
	</channel>
</rss>
