Inheritance from derived classes with AutoMapper

Simple scenario.  Base class is super simple and we have a derived class which adds some additional properties to it.

The problem is if you try to do a Mapper.CreateMap from your source to the DERIVED class, the properties of the base class are not include by default.

To achieve this:

Mapper.CreateMap<SourceClass, ExtendedClass>().IncludeBase<EventBase, EventExtended>();

 

Credit: https://github.com/AutoMapper/AutoMapper/wiki/Mapping-inheritance