Monthly Archives: May 2008

Matthieu Mezil’s new English blog

Matthieu Mezil is a Parisian who really digs .NET and the Entity Framework. He writes a lot about it in his native tongue (that would be French ;-)) in his blog.

Since my French, which I studied for 4 years in high school and college (which was a long, long time ago) is pretty rusty, I use google’s translation to get a gist of what he is saying in his blog.

But now that Matthieu is an MVP, he has started a mirror blog in English on the msmvps.com/blogs site.

So to recap

Matthieu Mezil in French

Matthieu Mezil in English

Command Execution of directly called ImportFunctions (stored procs) in Entity Framework

I hadn’t noticed this before.

If you have a stored procedure that is mapped to an entity such as "GetCustomersSince" which returns Customer entities, the command is executed when you create the query, not, like with normal queries, when the data is first needed.

In case that sentence was too convoluted…

Here is a LINQ to Entities query (the same is true for LINQ to anything and also for Object Services (context.CreateQuery))

Dim query= From c In context.Customers Select c

For Each cust in Query  <– command is executed here

‘do something

End For

But when calling a function import:

dim custs= From c in context.GetCustomersSince(New Date("2008","01","01")) <–command is executed here

For Each cust in custs

‘do something

End For

Looking at the code gen for the function I can see that ObjectContext.ExecuteFunction is called.

Responses to Danny Simmons "Why Entity Framework" post

I’m definitely interested in what people have to say about Danny’s post so I have subscribed to the Bloglines citations of it:

http://www.bloglines.com/search?q=bcite:blogs.msdn.com/dsimmons/archive/2008/05/17/why-use-the-entity-framework.aspx

RSS

Don’t forget the comment thread in Danny’s post as well.

Not surprisingly, the folks who have already made it clear that EF is way too data-centric for them are up in arms and there are some very interesting discussions in their blogs (as well as the comment threads).

I’m not sure if I would compare the investment I am making in understanding how EF works and writing a whole book to share what I’ve learned to being brainwashed by a "shiny brochure on your desk". Nor do I feel like a "cheerleader" or "parrot". But… whatever… (lame response? Yep! But it’s all I have time (or patience) for).

VB.NET Day in Waltham, MA: May 27th

Michale de la Maza follows up his popular C# day events with a VB.NET day at the Microsoft office on Tuesday May 27th.

Join us for a relaxed, no cost introduction to VB.NET programming. By engaging in participatory activities, you will learn some of the most common and powerful features of the VB.NET language. This day is not lecture-based. There will be fewer than 60 minutes of lecture material — almost all of the time will be spent on participant-guided activities. Everyone who attends will learn what interests them at their own pace in a relaxed, tension-free environment with an experienced VB.NET developer and trainer available to answer questions.

RSVPs are required and details are here.

Registration problems for Thursday’s MSDN Roadshow in Williston, VT? Here’s the fix!

The online registration system for Microsoft events is currently broken (or just acting really flakey).

If you are trying to register for Thursday’s free, full-day, Bob & Chris & Jim Roadshow , try the online registration first here:
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032378634&culture=en-US

If that doesn’t work, you can register by phone

Call the event system directly (877.673.8368) and use the event ID 1032378634.

For more information and details about the event, see Chris’ blog post here:

http://blogs.msdn.com/cbowen/archive/2008/05/02/the-roadshow-rides-again-may-june-edition.aspx

If you are trying to register for a different one of these Roadshow events, just get the EVentID from Chris’ blog.

If you are trying to register for other Microsoft events the phone # should be the same, but you’ll need to know the EventID of the event you are trying to register for.

Great fix in the EDM designer – Inheritance doesn’t trash mappings

In the earlier bits, if you changed an association to an inhertiance, the type that becamse the derived type lost its mappings and th emappings for any associations.

Depending on how complex that type is, recreating all of that could be challenging.

I just tried this out in the new bits and the mappings and association mappings all remain intact.

This is great and it will save a tree too, since I can go remove all of that explanation about how to deal with that problem from Chapter 5 of my book!

Safe Mode in the Entity Data Model designer

If you have screwed up your Entity Data Model, you may be familiar with safe mode when you try to open the model up in the designer.

But the mapping designer has Safe Mode now, too.

Here is what I get when I am in the middle of creating an inheritance in my model which means that some of my mappings are still a big goofy. I tried to get to the mapping details of the derived type and here is what I see:

The error messages for Entity Framework and the designers are really very helpful.

Danny Simmons on “Why use the Entity Framework?” – A must read

Having just done a presentation at DevTeach called “.NET 3.5 Data Access Guidance”, which I will be doing again at TechEd in a few weeks and I have a CoDe Magazine article on this topic coming up as well, it is definitely interesting to me to see what is probably the first somewhat official looking (it’s a blog post, not a white paper) guidance from someone at Microsoft about Why to use Entity Framework.  Outside of a direct comparison of LINQ to Entities vs LINQ to SQL by Elisa Flasko earlier this year , there hasn’t been a Microsoft white paper on Entity Framework since June 2006. That’s almost 2 years. And that was written when they were first going public with the technology. What Danny is doing here is definitely a first.

In my presentation/article I need to be objective. Granted I am only addressing what’s “in the box” – datasets, LINQ to SQL and EF, not nHibernate/ORMs. And I have to be sure not to lean towards EF, which is difficult not to do since I am so focused on it.

But Danny’s list is definitely right on. He is highlighting the benefits of EF compared to datasets, compared to LINQ to SQL and also compared directly to nHibernate. It’s funny how we (Danny, myself, maybe others) tend to include nHibernate, which has a LOT less users than datasets or LINQ to SQL in these discussions because it is the [relatively] small # of nHibernate users that make the most noise and Danny and I have both been beaten up quite a bit by them, so we now have a natural tendency to be sure to address them at every turn. I think it’s become self-defense measure more than anything else. (I shouldn’t really speak for Danny here, since he may have different reasons. I know that this is true for me, though.)

One thing that I need to do differently than Danny’s post when I do the overall guidance presentation is not just list the places where EF totally outshines the other options, but I also need to address areas where you may prefer the others.

Every time I have done this guidance presentation, I have had someone say to me after the fact, “but I really love typed datasets? Why should I move to EF or LINQ to SQL”. My response to them is that if after seeing my presentation, if there is nothing that was truly compelling to them to want to make the change, then typed datasets are probably just the right choice for them.