I have a data layer that contains my EF6 DbFirst edmx, repositories, and auto-senses.
I also have a model layer with Poco for each automatically generated object in my data layer. The properties are almost identical, with the exception of a few name changes.
AutoMapper is installed only for my DataLayer, and it is there that I install all my mappings in the configuration file. At this point, I have a mapping of each DataLayer with each ModelLayer and each ModelLayer for each DataLayer. Any name changes are indicated in the mappings.
Since it is configured this way in my storage methods, the function takes an object from ModelLayer, but then maps to a DataLayer, so I can send it to DbContext. When retrieving information in my repository, I use DbContext to retrieve and then the AutoMapper function to map to Model so that the function returns as Model.entity.
My business layer and web application use models only. If something seems wrong, let me know.
Another thing is the mapping from ModelLayer to ViewModel and vice versa during GET and POST actions in my controller. Is it ok to display both paths here? Should I install AutoMapper in my web application at this point?
source share