Entity Framework in a SOA environment

17 במאי 2009

תגיות: ,
5 תגובות

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.


הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

5 תגובות

  1. Rotem Bloom17 במאי 2009 ב 18:01

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

  2. Marat18 במאי 2009 ב 15:44

    Great article, buddy.
    Get your feet wet!

  3. Rudi Breedenraedt6 ביוני 2009 ב 18:35

    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:

    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.


  4. blogs.microsoft.co.il20 באפריל 2011 ב 15:43

    Entity framework in a soa environment.. He-he-he 🙂

  5. http://user.qzone.qq.com/1750405051/blog/135183942315 בנובמבר 2012 ב 23:04

    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 http://user.qzone.qq.com/1750405051/blog/1351839423