views:

2239

answers:

7

I have a project that implemented Linq To SQL, and I was pretty happy with it. For quite awhile the biggest problem was just that the designer was buggy.

Unfortunately, my project now requires multiple table inheritance, and Linq to SQL does not support it. I decided to switch to Entity Framework when I learned that it does support multiple inheritance and seems to be the direction Microsoft is heading. But now I'm starting to regret that decision.

For instance, calling Load()? WTF? If I didn't want that data, I wouldn't be asking for it! Figuring out all of Entity Framework's anal quirks is becoming a huge thorn in my side.

Anyway... is there a light at the end of the tunnel? When I'm all done, will using EF be worth while, or have I made a terrible decision?

Finally, I would like to ask: where has Microsoft been with the whole ORM thing? Rails' ActiveRecord has been working beautifully and simply for years now.

+6  A: 

Well, the VS2010 beta is available; you could spin up a virtual machine and see if EF in 4.0 suits you any better?

Personally, I've stuck with LINQ-to-SQL for now, but probably because I haven't needed any of the other features yet.

Marc Gravell
+1 for the L2S advice - I'm 100% with you on that one. As for EFv4 - features-wise they are making progress with EF (although it took me exactly 20 seconds to render a EF model unusable with the VS2010 beta's "update model from database" wizard). However, I am more concerned about the SQL generated by EFv4 - in the first round of tests I have done they haven't (yet) fixed the SQL generator bugs that generate monster queries with lots of redundant joins etc... ...oh well, it is still beta so maybe EFv4 RTM will be better...
KristoferA - Huagati.com
+10  A: 

You are not alone in your pain. There has been a series of posts on the ADO.NET blog discussing the enhancements that are being made to the Entity Framework in .NET 4.0. They seem to be pretty significant, but whether or not they are sufficient for your needs, only you can judge.

Thanks for the link. It definitely sounds like they're changing their goals in a positive direction. And it sounds like they're planning on using lazy loading in an accessible way.
grimus
+3  A: 

I'm actually looking forward to using Entity Framework in its v4 version hopefully Real Soon Now. Granted, in our case it's accompanied by getting rid of a god-awful-in-house ORM which is no longer supported, which is worse than the plague - so EF v4 looks like a god-send to me! :-)

Marc

marc_s
+3  A: 

I for one have been sourly disappointed with EF v1.0. It promised a lot, but in reality it was extremely restrictive, performed horridly, and did not support existing applications and infrastructures.

That said, EF v2.0 looks very promising. Microsoft has opened the design process to the masses, allowing those of us who wish to see EF succeed and see if fit into the wide variety of usage scenarios that it really should offer our suggestions, advice, and opinions.

If you are interested in seeing the results of this effort, or want to provide your own input, you should check out the EF Design Blog, here: http://blogs.msdn.com/efdesign/

In the end, if Microsoft is still not capable of producing a flexible ORM that fits into a wide variety of scenarios, there is always NHibernate. I've been using LINQ to SQL, Entity Framework, and NHibernate for a while, and of the three, NHibernate is the most friendly, flexible, and mature framework. It does not have much in the way of visual designers, but if your frustrated by the limitations, quirks, odd behavior and bad performance of EF, NHibernate is a great alternative.

jrista
Thanks for the advice. I think if I was to start the project over again, I would have gone for NHibernate from the beginning.
grimus
+3  A: 

For a follow up:

I've given up for the time being on Entity Framework. The code rewrite has been tramatizing and I'm not at all happy with the result... largly due to the lack of lazy loading support.

I've decided to go back to Linq to SQL and try out the single table inheritance for now. We don't have very many child types, so for the time being, it should be an ugly but acceptable solution. When the new version of VS and Entity Framework are released I'll consider switching again at that point because the changes for the new version look promising.

grimus
I also started of with EF, and decided to go back to good old Linq2Sql. Not only are the quirks gone, Linq2Sql also builds better/faster SQL in some cases (EF doesn't use the LIKE statement for example).
Gidon
+3  A: 

I absolutely agree. Lazy loading is what killed the entity framework for me. It just opens a can of worms with attaching and detaching entities to the context instance. I really don't want to worry about these things. But then who hasn't worked with a half-assed product from Microsoft before :) I'm glad they're going to be patching things up in a new release. Until then L2S seems like your best bet.

Sergey
A: 

Not an answer per se, but still probably a solution; ActiveRecord...

Thomas Hansen