Geeks With Blogs
Sudheer Kumar ASP.Net, C#, BizTalk, MSBuild, WPF, WCF, WF....

If you are planning to choose Linq to Entities data model for you projects, please read-on.

Linq-Entities (LE) still doesn't have many of the features that are present in LINQ-Sql (LS). The following are the major things which came across during m development.

This article assumes that you are familiar with both.

 

  1. LE doesn’t have proper support for Stored Procedures (SP):

LS can import a PS to DBML file or using SqlMetal and can invoke it directly from the context and during import a type is automatically defined for the return data from the SP.

 With EF, you cannot invoke the SP on the data context as used to be with LINQ.

You can do it using an extension provided EFExtensions:

http://blogs.msdn.com/meek/archive/2008/03/26/ado-entity-framework-stored-procedure-customization.aspx

But MS doesn’t guarantee that it will be supported in future.

 

If you import SP using EDMGen.exe, you will be surprised to see that EDMGen has no switch that imports a Stored Procedure mapping to CSDL and MSL. That means you have to manually do the importing to CSDL and MSL files..!

  1. LS supports Outer Joins, but LE has crippled support for outer joins.

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/a3f2b146-750b-435c-b48c-2ea301bf130f/

 

  1. LS can join with List<T> where are LE can’t do the same.
  2. LE doesn’t practically support the SQL IN clause:

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0/

 The work arounds are very messy.

         5. You can't use the extension methods like Any() in LE, but they work well in LS

Also see this blog:

http://www.kindblad.com/2009/01/11/why-you-should-not-use-the-adonet-entity-framework/

LE is a crippled solution in the sense that LE promotes using the Lambda expression for querying the database entities, but these Lambda expressions doesn’t support many basic SQL operations.

And there is no proper support for Stored Procedures.

LE is projected as a superior solution that LS, but LE doesn’t support many features of LS.

I have no words to express my frustrations..!

 

Update [06/08/2009]

Found a better solution to do left outer join with EF

http://oddiandeveloper.blogspot.com/2008/12/testable-left-outer-join-in-linq-to.html

 You can flatten a left-outer-join as follows:

 var v = from en in context.Entity.Include("PostalAddress").Include("PostalAddressType")
                    let leftouter = (from pa in en.PostalAddress
                                                                select new {
                                                                                      PA = pa,
                                                                                      PAT = pa.PostalAddressType
                                                                                     }).FirstOrDefault()
                    select new {
                        EntityID = en.EntityID,
                        PostalAddressID = (Guid?)leftouter.PA.PostalAddressID,
                        PostalTypeID = (Guid?)leftouter.PAT.PostalAddressTypeID
                    };


Posted on Wednesday, June 3, 2009 10:10 AM | Back to top


Comments on this post: Think MANY TIMES before choosing Entity Framework

# re: Think MANY TIMES before choosing Entity Framework
Requesting Gravatar...
You might consider looking at EF4 (the next release of the EF). It's currently available in beta form, and it supports many if not all of the things you mention above.

- Danny
Left by Daniel Simmons on Jun 04, 2009 11:37 PM

# re: Think MANY TIMES before choosing Entity Framework
Requesting Gravatar...
I disagree Danny.
I had to find all these things the hard way, during the development of a project.
Am I supposed to use EF4 beta for developing the product?
It is not a good practice to release a product with a lot of missing basic features and letting people find the issues the hard way..!
Left by Sudheer on Jun 05, 2009 7:29 AM

Your comment:
 (will show your gravatar)
 


Copyright © Sudheer Kumar | Powered by: GeeksWithBlogs.net | Join free