Chapter 22. Implementing a Smarter WCF Service for Working with Entities

In a world where services are increasingly being used to enable distributed computing, no one can take services lightly when approaching the Entity Framework. As with web applications, using services to provide read-only information to client applications is pretty straightforward. However, when you want those clients to be able to update data through your services, the Entity Framework’s change tracking breaks down as you try to move data across tiers, and it creates big problems for performing updates.

In Chapter 14, you wrote your first services using the Entity Framework. The ASMX Web Service demonstrated a simple solution whereby single entities were sent to explicit insert, update, and delete operations. No graphs were involved in the messages being sent to the service. The WCF service in the second half of that chapter went a step further and worked with graphs. This introduced the challenge of determining the state of each child in the graph that came back to the service. You may recall using assumptions such as “if an entity’s ID is 0, it must be new.” You also forced the client to send the deleted entity IDs in a separate object within a data contract. This worked, and it leveraged your existing knowledge of the Entity Framework at that point in the book. But the service was complicated, it forced the client to do a lot of extra work, and in some programming scenarios those assumptions just won’t work. ...

Get Programming Entity Framework now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.