I read a couple of articles and questions related to layered architecture in ASP.NET, however I got a bit confused after too much reading. The UI layer is developed in ASP.NET MVC and for the data access I use EF in my project.
I'd like to describe my problem through an example. Let's say I have a simple blog engine, with the following entities: Post, Comment, Category, User. I use EF database approach and generate POCO-s in my model layer to a data model class library, the generated datacontext and the EDMX goes to the data access library.
Above this I have a business layer. This is responsible for example to return a blog entry with comments. In my UI layer I'm using ViewModel classes because for displaying an entry I need both a Post entity and a list of Comments with usernames on the same view.
And now my problem: My view doesn't need every details of a User entity, just the name in order to display a post. The question is where should I do the mapping between my ViewModels and Model classes? Should the business layer do this? Or I should return the entities with every details and let the UI handle the mapping? Should the business layer contain ViewModels as a class library?
What is the best approach for this?