Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 4.0: is it worthy now?

I've read a lot complains about Entity Framework in .NET 3.5 SP1, especially about its ineffectively generated SQL. Those complains had prevented me from studying Entity Framework.

Now Entity Framework 4.0 has come out, which provide a lot of promises. I wonder if it's really a good ORM now, or still not yet? Is it worth to learn and use it in my .NET projects, instead of traditional SQL queries? Have you planned to switch to EF 4.0 yet?

Thanks in advance.

like image 263
Quan Mai Avatar asked Sep 22 '10 07:09

Quan Mai


4 Answers

One word: YES!!

Entity Framework 4.0 contains a huge number of additions and improvements, and with the additional templates for POCO's and self-tracking entities, it's definitely ready for prime time now.

If you want to, you can even go so far as to define your entire EF "model" in code - no *.edmx file at all - looks and feels a lot like Fluent NHibernate. You have lots of options with EF4 - and that's a good thing, and a sign that the ADO.NET team really did listen to the community (and work very hard to make those things a lot better now).

In addition to Julie Lerman's book and blog, you should also check out the ADO.NET EF4 team blog - it contains very useful and helpful hints and tips.

This blog post in particular might be of interest to you:

  • Improvements to generated SQL in Entity Framework 4
like image 136
marc_s Avatar answered Oct 16 '22 10:10

marc_s


You should really check out Julie Lerman's blog on EF4, she's at once enthusiastic on the product, yet technically correct. As per me, I can tell you that we have already used EF4 in more than a couple production projects with good results :-)

like image 25
Édgar Sánchez Gordón Avatar answered Oct 16 '22 10:10

Édgar Sánchez Gordón


Yes, EFv4 (in .net 4) is in a completely different league than EFv1 (in .net 3.5 SP1).

EFv1 had a lot of limitations and it sometimes generated horrible T-SQL.

The TSQL generated by EFv4 is fine as far as I am concerned; sometimes it has a bit more nesting with subqueries than needed but that is a cosmetic thing that only affects human readability...

like image 2
KristoferA Avatar answered Oct 16 '22 09:10

KristoferA


If you need ORM and you are limited to .NET Framework then yes EF v4.0 is major upgrade and it is much better than EF v1. But on the other hand it is still only second version and a lot of problems are not solved yet. Also mentioned code first development (no .edmx) is only CTP version which is not ready from production usage. But I believe you can successfully use EF in any kind of project and you will still get some added value in quicker development.

Among limitations you can think about:

  • Limited mappings
  • Worse experience with EDMX in shared environment
  • Bad experience in disconnected scenarios
  • No build-in tracing
  • Limited extensibility, no hooks
  • etc.
like image 1
Ladislav Mrnka Avatar answered Oct 16 '22 10:10

Ladislav Mrnka