DCSIMG
Entity Framework in a SOA environment - David Birin's blog

Entity Framework in a SOA environment

I received a mission to explore entity framework as a DAL for a new project, this project is intended to be N-Tier SOA application.

Here are some of my findings:

  • The partial classes which are created by entity framework already contain DataContract and DataMember attributes and are “ready to use” in WCF.
  • Entity framework has a change tracking mechanism, the main problem with this mechanism is that once the object was serialized (before transferred in a service) it gets the state “detached” and from there on it doesn’t track changes until reattached to the graph (read more here).

The second issue is a major disadvantage in comparison to typed datasets, which has the ability to track changes in any tier (using DiffGrams).

There are few community projects which try to overcome this issue by developing their own type of DiffGram for entities (some of them can be found here and here), But after testing these project (and using SQL server profiler) we found out that there are 3 major issues that we couldn’t find a solution for all of them together in any of the community projects, the issues are:

  1. Performances (we saw that one solution made 17 select statements to the DB before updating a single entity).
  2. Updating entities which are connected by foreign keys to another entity (not supported by some solutions and problematic in others).
  3. We don’t want to create a 3 service functions for each Entity in example: UpdateCustomer(CustomerEntity c) , AddCustomer(CustomerEntity c) and DeleteCustomer(CustomerEntity c). We just want one single function:
    CommitChanges(EntityObject e). We found that implementing such a function could be a very complex task.

But not everything is so bad, it appears that the ADO.NET team at Microsoft is aware of this issue, and in EF4 (VS2010) there will be a solution for these problems called  “self tracking entities” (as you can read here and here).

To sum things up, my personal opinion is that until the “self tracking entities” mechanism will be implemented, this technology is still not mature for large scale SOA projects and requires many tweaks and infrastructure work.

David

Published 17 May 2009 09:42 AM by DavidBi

Comments

# Rotem Bloom said on 17 May, 2009 06:01 PM

אחלה של אינפורמציה תודה

# Keeping Green » Entity Framework in a SOA environment - David Birin's blog said on 18 May, 2009 05:09 AM

Pingback from  Keeping Green  » Entity Framework in a SOA environment - David Birin's blog

# Keeping Green » Entity Framework in a SOA environment - David Birin's blog said on 18 May, 2009 05:09 AM

Pingback from  Keeping Green  » Entity Framework in a SOA environment - David Birin's blog

# Marat said on 18 May, 2009 03:44 PM

Great article, buddy.

Get your feet wet!  

# Rudi Breedenraedt said on 06 June, 2009 06:35 PM

Hi David,

Good analysys, and I do agree with your general conclusion that the next version of EF, EF4, will be an important improvement.

Nevertheless, I did myself some 'research' about the 3 issues you mention (well, actually mainly about the 2nd one), and came to a different solution than the ones you list in your post.

I've published my solution under:

www.codeproject.com/.../attachobjectgraph.aspx

It addresses the 3 issues you mention. The 'preload' I added in the second release ensures a single DB roundtrip is made when editing an existing objectgraph where the relations did not change. The second issue is addressed by the idea that a while objectgraph (multiple related entities) is to be handled, and about the 3rd issue, although a very generic 'CommitChanges(justAnything)' is not supported, a single 'SaveProduct' will be able to handle different kinds of updating including setting a new supplier etc.

Self-tracking entities may sound great and easy to use, but you should also realize that a 'CommitChanges(justAnything)' method also represents a security breach as it can be used to post requests that are not meant to be supported. It's really something like an 'ExecuteThis(sqlString)' operation: without very serious checks such an operation can be misused.

Regards

# blogs.microsoft.co.il said on 20 April, 2011 03:43 PM

Entity framework in a soa environment.. He-he-he :)

# http://user.qzone.qq.com/1750405051/blog/1351839423 said on 15 November, 2012 11:04 PM

The electronic cigarette makes use of a battery and a small heating aspect the vaporize the e-liquid. This vapor can then be inhaled and exhaled

toms user.qzone.qq.com/.../1351839423

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: