June 2, 2008

DevDays 2008 impressions

Filed under: .Net,ADO.Net Data Services,Entity Framework,Events,Microsoft — Freek Leemhuis @ 1:31 pm


The keynote this year was titled ‘Why Software Sucks’, by .Net professor David Platt. I’ve missed most of it while lining up to get tickets (thanks Mark ;-)) , but it was basically the same session that Platt has been delivering for a number of years now, most recently in TechEd Barcelona in 2007, and I was a bit surprised when I found out this talk was now promoted to keynote for the DevDays. Must have been a slow day at the office for original content or new announcements….
If you’ve not seen Platt’s talk before, it’s pretty entertaining. You can watch it (from a similar session) online here.

Silverlight 2.0

The session from Daniel Moth was about Silverlight 2.0. Where previous versions of Silverlight were all about media, video delivery etc, you could only program in javascript to make things happen. With version 2.0 you can finally write managed code to run in the browser. This, combined with the power of XAML makes for a very compelling platform to deliver RIA’s (most self-respecting conferences these days includes a RIA (Rich Internet Application) track). Silverlight 2 of course was announced during Mix, so if you want to check it out go watch the sessions on Silverlight on They’ve recently redone the sessions so that the streaming includes the presenter as well as a separate stream to show the slides and demo’s.

The ADO.Net Entity Framework

The ADO.Net Entity Framework session from Mike Taulty was a good introduction into the subject. Mike pointed out a new website where you can find news, tutorials and other resources on new data technologies such as the Entity Framework and the ADO.Net Data Services. I was a bit puzzled when Mike spend considerable time of his session on how you can still use the old-fashioned ADO api (datareader, command) to program against the EF. I can think of only a small number of cases when you’d want to do that.
Check out this webcast for more details on the EF.

WCF on the Web

For me, the most interesting session of the day was delivered by Peter Himschoot, who showed what additional work has been done in WCF for the web in version 3.5. More specifically, WCF now supports JSON and REST. It’s interesting to see that a framework like WCF has been designed to a high enough level of abstraction that, while it was build when services were all very much soap-oriented, it has now been extended to include new concepts like JSON and REST.

ASP.Net MVC Framework

On the Friday, Alex Thissen kicked off with an introduction to the MVC framework. The MVC framework will be an alternative to the current webforms model. It allows the programmer to control the HTML markup, rather then having it generated by user controls. It does away with postback and viewstate, so you get a much cleaner model, that allows for better Separation of Concerns and better testability. As always, Alex is very thorough and I was impressed to see he managed to sprinke Unity and Moq in his demo without loosing the audience.


Next up was Anko Duizer who discussed various options to include LINQ to SQL in your architecture. Do you regard LINQ to SQL as your data layer, or do you just use it as part of your datalayer? This was a good follow-up to Anko’s previous introductory sessions on LINQ to SQL, and it addressed some of the difficulties that you can run into when you need to figure out the best practices for leveraging LINQ and LINQ to SQL.

ADO.Net Data Services

Mike Taulty then had another session, this time on the ADO.Net Data Services (codename Astoria). Using this technologie you can take a data model like LINQ to SQL or an Entity Framework model, and make the classes available through REST-based services. The framework will be made available in service pack 1 for Visual Studio 2008, currently in beta.


Marcel de Vries showed some of the new features of Rosario, the upcoming new version of Visual Studio and the .Net framework. His talk focused mostly on Team System. The primary goal of the new Rosario features is to bring together the three main stakeholders of a software project — business and IT governance, IT operations and development. Some of the new features include:

historical debugging: a new testrunner application allows a tester to record test runs, which can then be replayed on a programmer’s machine, thereby reproducing the bugs that the tester has stumbled upon, but also creating a debug session where there previously was none!
This should get rid of some ‘but it works on my machine’ discussions….

Functional testing– codename Camano- : a test manager for running functional tests. It provides test execution assistance, workflow, rich bug logging and reporting.

Marcel also showed some features of the Team Architect edition, that now includes… UML support! Ever wished you could generate a sequence diagram from existing code? I had noticed this through Clemen’s blog and I’m a bit puzzled to see Microsoft performing this U-turn, where they have previously stayed well away from anything related to UML. I’m intrigued enough to go and try this out to see how valuable the additions will be.

Dynamic languages and the DLR

Finally, I managed to catch Harry Pierson‘s session on dynamic languages and the Dynamic Language Runtime (DLR).  I have a fascination for the differences between different programming languages and paradigms, and the initiative from Microsoft to enable the use of existing dynamic languages on the .Net platform is a very interesting one.

The question many people who are using a statically typed language on the .Net platform will pose is: why would I want to (also) use a dynamic language. Harry really brought it home to me: with the DLR and the supported languages Microsoft aims for the developer that is currently using Python or Ruby, and get them on board by making it easy for them to switch to the Microsoft platform.

So, if you’re not currently using dynamic languages, should you care about this stuff? Well, if you are a believer in polyglot programming you should. This is the idea that within an application you would use multiple languages, and you select the language that is best fits the particular concern you’re trying to address. For example, in a Model-View-Controller application, you would write the view in HTML and javascript, the controller using a dynamic language like IronPython and the model in a statically typed language like C#. Read the chapter on polyglot programming in the recently released Thoughtworks Anthology for more information.

One interesting thing to note on the DLR is that the original plan for the DLR was to release it with four languages that were going to be supported: IronRuby, IronPython, JavaScript and VBX, where the last one was a new dynamic variant of Visual Basic. The last one has now apparently been dropped, and the DLR will be released initially with just the first three languages. It looks like Microsoft has not yet made its mind up considering the future of VB. 

When .Net first came out, the differences between the implementations of VB and C# were surprisingly few, and the choice of customers between these two would invariably hinge on the history and familiarity of their existing programmers base, rather then on the merits of the particular language.  With the recent additions in VB like xml literals, these languages seem to start to drift apart again, and I would very much like to see people preferring one over the other because they like the language features better, not just because it’s what they are used to.

So the question is, will Microsoft rediscover VB as a dynamic language? That’s why I was curious to see how the VBX implementation for the DLR was taking shape…. I spoke to Harry about this, and he was rather tight-lipped about it but hinted that we might get an announcement on these issues at the upcoming PDC.

And so..

All session on DevDays were recorded on video, so I’ll keep you posted when materials will be made available online. If you attended, let me know what you thought…



March 10, 2008

LINQ to SQL vs the Entity Framework

Filed under: Entity Framework,Linq — Freek Leemhuis @ 10:16 pm

I have done a number of technical sessions on Linq, Linq to SQL and the ADO.Net entity framework recently. I will try to put together a number of posts here for those who want to get started on these technologies. One of the questions I get asked regularly concerns the difference between the different frameworks. I will try to highlight some of these in this post.

Since we had the lauch of Visual Studio 2008 last week, Linq to SQL is now widely available. Linq to SQL is a light-weight OR-Mapper. Is this the best framework for persisting your data? No, by no means. If you are currently using a feature-rich OR-Mapper like NHibernate or LLBLGen, you wouldn’t want to switch to Linq to SQL. However, if you’re new to the practice of OR mapping, Linq to SQl can be a good choice to get you started. 
Included in the ASP.Net 3.5 extension pack that’s going to ship sometime this year is the ADO.Net Entity Framework. This has all of the capabilities of Linq to SQL, and much more. To give you an idea, I’ve outlined the differences between these frameworks below:

Linq to SQL

Entity Framework
RAD scenarios Enterprise development
Data centric (1 table maps to 1 data class) Conceptual modeling
Inheritance modeling

  • Single table inheritance
Inheritance modeling:

  • Single table inheritance
  • Table per subclass
  • Table per concrete class
One API(Linq) Three API’s (linq, object services, entity client)
MS SQL Server only Provider model(SQL Server, Oracle, MySQL etc)
Out now. Somewhere in 2008

This lists the main differences, but there is much more to tell. For now, let’s focus on the different ways these frameworks model the data classes.  You can generate a model in Visual Studio from an existing database by dragging tables from server explorer onto the designer canvas. Using Linq to SQL on one of my demo databases, the following data classes are generated:


Notice that we have a many-to-many relationship in the database: A person can be linked to one or more companies,  and a company can have a link with one or more persons.

Now if we import the same database using the Entity Framework we get a slightly different result:


First thing you will notice: the CompanyPerson table has no corresponding data class. This is what we want! This table is just a construct that is used in relational database modelling to enable the Many-to-Many relationship, but it is not an entity in our OO model, and should therefore be abstracted away by the framework of our choice. In the EF, you can see how the mapping is done through the Mapping Details:


We have a navigational property Companies for Person, and likewise a Persons property on Companies. Using Linq to SQL we would have to use the CompanyPersons data class (yuk) or we would need to write custom navigational properties to get the same result. This is just the sort of stuff we want a framework to do for us! It would seem that the ado team that is producing the EF has put considerable more effort into the translation of relational to OO concepts. Looking at the two different models, you might have notice another key difference(pardon the pun): the noticable absence of foreign keys in the dataclasses of the EF. We have a navigational property Country on the Person class, and from Country we can navigate to persons. Why would we want an attribute CountryID in our Person data class?

Next time I will dig a bit deeper into Linq to SQL.

Create a free website or blog at