entity-frameworkarchitectureself-tracking-entities

EF + WCF in three-layered application with complex object graphs. Which pattern to use?


I have an architectural question about EF and WCF. We are developing a three-tier application using Entity Framework (with an Oracle database), and a GUI based on WPF. The GUI communicates with the server through WCF.

Our data model is quite complex (more than a hundred tables), with lots of relations. We are currently using the default EF code generation template, and we are having a lot of trouble with tracking the state of our entities.

The user interfaces on the client are also fairly complex, sometimes an object graph with more than 50 objects are sent down to a single user interface, with several layers of aggregation between the entities. It is an important goal to be able to easily decide in the BLL layer, which of the objects have been modified on the client, and which objects have been newly created.

What would be the clearest approach to manage entities and entity states between the two layers? Self tracking entities? What are the most common pitfalls in this scenario?

Could those who have used STEs in a real production environment tell their experiences?


Solution

  • STEs are supposed to solve this scenario but they are not silver bullet. I have never used them in real project (I don't like them) but I spent some time playing with them. The main pitfalls I found are:

    I described today the way to solve this without STEs. There is also related question about tracking over web services (check @Richard's answer and provided links).