Monday, November 12, 2007

LINQ to SQL and Entity Model: separated at birth? Part 1

I've been hearing and reading about LINQ to SQL from some time now. Last year at TechEd 2006 something called Entity Models was hinted at and a CTP came out spring 2007. The promises are the same: you extract from your database a object model that you can modify and voilĂ , you have a data/business layer for your project.

Until recently I must have got things mixed up in my mind because I was thinking that Microsoft was going to make it's entry in .Net ORM with a new product. Instead I discover they are making their entry with two products. So we have LINQ to SQL coming with Visual Studio 2008 and ADO.Net Entity Model coming sometime Q1 2008, probably coinciding with the release of MS SQL Server 2008.

Oh, and to give it a real twist, you can do LINQ to Entities to do LINQ-style queries on Entity Model objects. Well, this at least proves that LINQ itsefl is getting some serious backing, the question will be whether LINQ to SQL will get such good backing when Entity Model comes out.

Life is all about choices and I like to have alternatives but there I was in Barcelona looking at very cool demos of Entity Model and LINQ to SQL and wondering if in some schizophrenic episode someone at Microsoft decided to do the same thing, twice... and differently!

So I decide to follow the sessions that discuss these things and the perfect occasion shows up: a "Interactive Session" very aptly titled LINQ to "X", ADO.Net Entity Model Framework, DataSets & Co - What is it with all these Data Access Technologies?. Kudos to Microsoft for such a daring title and putting such a great panel of experts.

The session started by explaining the two cheats of papers that where left on each seat. So, we get paper to write down our questions and send them to the panel for answering. With a grim I immediately start witting down two questions:
  1. Why are there both LINQ to SQL and Entity Model?
  2. Why is there LINQ to Entity Model queries and eSQL queries?
When this questions made their way to the panel, the first one was introduced as "the million dollar question". Paraphrasing Luca Bolognese's answer, and as I was starting to suspect, LINQ to SQL is to be a RAD oriented tool. It'll let you quickly build up a data layer for non-industrial applications in a similar way then DataSets do today. With the big advantage of letting you do that without a single line of SQL if desired/necessary.

On the other hand, Entity Model is going to be LINQ to SQL's bigger, more mature brother. Capable of more complex mappings (like several tables mapped to a single object) and better customization.

No comments: