Jeffrey Palermo (.com)

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300

First, none of this is NDA.  Others discussing it are Ayende and Sam.   Here's a quick rundown of how you would get Linq to entities working:

  • Create the metadata file using the wizard.
  • Select some database tables to map to objects.
    • Wait for the designer to generate the mapping meta data.
    • Wait for the designer to generate some partial classes that might serve as entity objects.
  • Add code to these new classes to do interesting things within your domain.
  • Using Linq queries to work with these objects and watch the SQL be generated and sent to the database.

This sounds easy  when you remember that the designer is generating all the ugly goo that _has_ to be there.  First, the classes must inherit from the mapping base class.  They are working on a way to make it implement an interface instead.  This is a non-starter first of all because it would require the domain assembly to carry around a reference to a data access dependency.  Next, for dirty-tracking, each property mutator must raise an event to let the framework know that a property changed.  Every property.  Let me repeat:  Every property setter must raise an event for dirty tracking to work.  This is another non-starter.  The team plans to have all this generated for you in partial classes. 

I have email addresses for several people on the team, and I'll be letting them know what is so compelling about NHibernate and why the above issues have to be resolved before RTM and not after.

In some cases, you don't care if the classes are data-transfer objects instead of domain objects.  In that case, use Linq to SQL, not Linq for Entities.  With Linq to SQL, you can use DTOs all over the place and work with the data pretty easily.  Heck, you could even use Linq to SQL to create your own data layer for hydrating your domain objects manually from the DTOs you decorate with the Linq to SQL attributes.

Linq to Entities is a different animal and is meant to persist domain objects.  Domain objects ARE the most important part of the application.  The domain defines the business problem scope.  Persisting to a data store is secondary to the domain model's structure and behavior. 

I want Linq to Entities to succeed.  I want frameworks and tools to continually get better; therefore, I will be communicating with the product team to voice my strong concerns over the current direction.


Posted Thu, Mar 15 2007 12:40 AM by Jeffrey Palermo

[Advertisement]

Comments

Ayende Rahien wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Thu, Mar 15 2007 2:15 AM

@Jeffery,

I am finding it hard to get publicly available information about EF.

Can you point me to some sources?

Jeffrey Palermo wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Thu, Mar 15 2007 2:34 AM
Ayende Rahien wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Thu, Mar 15 2007 5:27 AM

I am sorry, I know all of that, and I already have the CTP.

What I am interested in is stuff beyond the very high level overview + maybe hello world.

sergiopereira wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Thu, Mar 15 2007 7:48 AM

@Ayende, I've trying to get on top of that too and I have been collecting some links. Maybe you can find one that you haven't seen yet over here: http://del.icio.us/sergiopereira/entityframework

Scott wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Thu, Mar 15 2007 9:05 AM

This is their second foray into this realm (remember ObjectSpaces?). It looks like the designer for this is different. My big question is: What's the ROI look like vs. using NHibernate/WilsonORMapper/LLBGen/Gentle.net?

Jeffrey Palermo wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Fri, Mar 16 2007 2:24 AM

I don't think there is any documentation yet, just the bits.  I spoke with the Entity Framework architects today, and the roadmap is actually quite bright, so I'm less concerned now.  I think they are on the right track, but it will take a while, so don't expect to have your domain-centric O/R mapper in Orcas.  I'm not sure what I can disclose, but I'll find out and blog an update.

Roger Jennings wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Fri, Mar 16 2007 4:25 PM
Sam Gentile wrote New and Notable 149
on Sat, Mar 17 2007 9:02 PM

Yup, I'm still stuck in Seattle and I still feel like crap. Tomas just went off to the airport and I

Angel Saenz-Badillos wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Mon, Mar 19 2007 6:45 PM

Ayende,

"I am finding it hard to get publicly available information about EF"

Interesting comment, I would like to know what you feel is missing from the EF message.  Our blog at http://blogs.msdn.com/adonet/default.aspx is fairly active, if you don't see something that interests you feel free to post a comment there

ScottBellware wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Wed, Mar 21 2007 11:12 PM

> it would require the domain assembly to carry around a reference to a data

> access dependency

Jeffrey,

This isn't really a problem unless you've got a constraint that doesn't allow you to distribute the domain object component with the data access component, or a constraint that suggests that it's inappropriate to do so.  Most web apps don't have this constraint, but many distributed smart client apps would.

Components are only units of distribution.  The only real force dictating their shapes is the app's distribution model.

system.data.objects dev guy wrote A delay before I write more about persistence ignorance...
on Tue, Mar 27 2007 10:33 PM

I've promised to write more about persistence ignorance in the Entity Framework, and while waiting for

Colin Jack wrote re: Linq to Entities: Microsoft's first go at O/R Mapping (they need our feedback now!) - level 300
on Tue, May 22 2007 3:32 AM

Yikes. Deriving from a few interfaces isn't the end of the world, not great but we could do it, but the properties bit is just awful. If its auto generated then it is not so bad but still....