devlord
devlord

Reputation: 4164

Repository pattern with Entity Framework Entities vs Business Objects

In a code-first implementation of EF, used along with a Repository pattern, should the repository return business objects from the domain model, or simple entities from the data model?

From what I can tell, the point of Repository is to return business objects, not entities, so that you can do work with them. But most of the code examples I find are returning data models instead, which seems like a bad idea to me because what if the data source changes?

Upvotes: 1

Views: 608

Answers (1)

Jayantha Lal Sirisena
Jayantha Lal Sirisena

Reputation: 21366

If you are using CodeFirst development you can easily use your business object as the data model as well. You can write Ef mappings in a separate DLL to remove the dependency of EF to business model. If you want to change the data source to another one instead of EF you can keep the same Business(domain) classes for that as well.

Upvotes: 1

Related Questions