Home  /  Questions  /  Question

50   50
Feb 08, 2013

Code First Entities and Data Access Objects


I recently purchased Patterns in Action 4.0.

Given the example code, with regard to the WPF/MVVM implementation, the Entity Framework Implementation folder in the Data Layer has Data Access Objects that interact with the auto-generated partial classes that come from using a Database First or Data Model First approach. All of these Entities inherit from EntityObject.

Coming from a Code First approach, and given the mapper inside the ModelMapper folder in this project, if I hand rolled my own entities would I refactor the mapper to map the existing Data Access objects to these "Code First" entities?

I am asking this because I am confused about the role of these new Code First entities as it seems like with the data annotations and custom attributes one can apply to these entities that they somehow are different than the auto-generated entities from the other "approaches". In fact they look a lot like, and seemingly can take on the role of a Business Object.

Thanks for the answer and thoughts.