Chapter 24. Building Persistent Ignorant, Testable Applications

One of the significant additions to Entity Framework in .NET 4 is its support for separating concerns in your application architecture, which not only leads to cleaner architecture and more maintainable code but also enables better testing practices. Entity Framework now allows you to benefit from the Entity Framework without forcing every part of your application to be aware of the Entity Framework, separating entities from the infrastructure. You can create classes that can focus on their business rules without regard to how they are persisted (where the data is stored and how the data gets back and forth between your objects). You can also create unit tests for your applications that don’t force you to interact with the ObjectContext and data store.

The POCO support that you learned about earlier in this book provides the foundation for these capabilities. Together with this POCO support, the IObjectSet interface that was introduced in .NET 4 enables you to separate the concerns of your various application layers. You’ve already worked frequently with ObjectSet, which is the Entity Framework’s concrete implementation of IObjectSet.

This chapter has two separate goals. The first is to provide information for developers who are already designing applications in this way and are interested in bringing the Entity Framework into the sphere of their development practices. The second is to ensure that developers who are unfamiliar ...

Get Programming Entity Framework, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.