I had someone email me a question today about POCO, IPOCO, persistence ignorance and the EF, and I responded to them with a summary of sorts which I thought might be helpful to some other folks, so I'm going to post it here as well. There's not a change in direction--just a further explanation of what we're doing--so if you've been following this topic for a while there won't be anything new for you, but maybe this will help other folks wade into the topic more easily when it comes up in the future. If after reading this, there are further questions, please don't hesitate to ask. I'd like to make sure that the message here is as clear as possible.
This whole space represents a continuum which looks something like this:
The EF started out as a framework which only supported prescriptive classes. Based on customer feedback we decided that it would be very important to support a greater degree of persistence ignorance for some scenarios, but we also believe that the prescriptive classes are great for other scenarios. So, we expect that overtime we’ll need to support this whole spectrum.
For the first release of the EF, we will support prescriptive classes and IPOCO. That is, you can have classes that do not inherit from our base class, but they must implement certain interfaces and they must have specific attributes in order to work with the EF. Right now there is a set of three interfaces, of which one is required (IEntityWithChangeTracker which is used for the object to communicate to the EF when the values of its properties are changed), one is required for any object which participates in persisted relationships (IEntityWithRelationships -- of course almost every object in a real system will participate in relationships so this one is pretty much also required), and one which is optional (IEntityWithKey – if you implement this then your object must have a property for storing the EntityKey, but in return parts of the system become faster/easier).
In future releases, we will work to make the remaining interfaces optional as well as to make it possible not to have any specific attributes on the classes but instead to specify all of that metadata in some other form outside the assembly containing the classes that will be persisted, but we were just unable to get all the way there in the first release.
No doubt a search of the web will turn up a variety of discussions on this topic, but here are a couple of my blog posts which provide some background reading in case you are interested:
- Danny