Repository pattern and mapping between domain models and Entity Framework

后端 未结 6 1177
后悔当初
后悔当初 2020-12-04 07:15

My repositories deal with and provide persistence for a rich domain model. I do not want to expose the anemic, Entity Framework data entity to my business layers, so I need

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 07:58

    With entity framework, across all layers IMHO, it is generally a bad idea to convert from entity models to other form of models (domain models, value objects, view models, etc.) and vice versa except only in the application layer because you will lose a lot of EF capabilities that you can only achieve through the entity objects, like loss of change tracking and loss of LINQ queryable.

    It's better to do the mapping between your repository layer and the application layer. Keep the entity models in the repository layer.

提交回复
热议问题