I suspect there is some simple configuration with AutoMapper to get the mapping I want, but I have no clue. Can anyone point me in the right direction?
Here is my situation:
I've defined table-per-type inheritance in Entity Framework with a supertype of Publication and a sub-type of Article (+ 5 other sub-types)
ArticleAdmin is my (MVC) viewmodel, which inherits from a PublicationAdmin viewmodel.
Mapping the viewmodel to the domain sub-type works fine:
Mapper.CreateMap<ArticleAdmin, Article>();
var _Article = Mapper.Map<ArticleAdmin, Article>(article);;
And so I have no problems adding articles.
But going the other way doesn't seem quite so easy. This won't populate the sub-type fields:
Mapper.CreateMap<Article, ArticleAdmin>();
var _Article = Mapper.Map<Article, ArticleAdmin>(_article_entity);
UPDATE
I've revised this, as part of the problem was that my generic repository was returning an entity of the super-type, instead of the sub-type . Now the domain-to-viewmodel mapping compiles, but it still maps nulls to the sub-type fields, while correctly mapping the super-type fields.