I am looking to setup architecture for entity framework that will break apart the entities into multiple models. What I am wondering if it is possible to code-generate one set of entities, so that each model uses the same set of data access classes? I realize the issue with contexts, but I was wondering if each context really needed to have its own set of classes, or I can create many contexts but only have one set of classes that represent the backend tables, using the self-tracking entities generation feature.
Thanks.
You can definitely share POCO classes across multiple models.
For example a class like this:
Would work in an EDMX that defines
PersonasID,Firstname,SurnameAnd would work in a second EDMX that defines
PersonasID,Firstname,LastnameNot sure though about Self-Tracking Entities, STEs are ‘POCO’ but they also have some model specific code which might break if the definition of the EntityType is different in your two EDMXs (like in my above sample).
You’d have to try it out.
Hope this helps
Alex (Former EF team member)