I have scoured the web and I can't figure out why in Automapper 6.2.1 I am having these issues. I have looked through many tutorials, guides and answers and come up with nothing.
I am getting this error:
Unmapped members were found. Review the types and members below.
Unmapped properties:
Title
Subtitle
ProductType
Language
Description
However I have created mappings for these properties. I'm not sure why I am having this issue.
I have created an AutoMapperConfig
class that is setup like this:
public class AutoMapperConfig
{
public static void Initialize()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Shop, SearchViewModel>()
.ForMember(x => x.Title, opts => opts.MapFrom(x => x.TITLE))
.ForMember(x => x.Subtitle, opts => opts.MapFrom(x => x.SUB_TITLE))
.ForMember(x => x.ProductType, opts => opts.MapFrom(x => x.PRODUCT_TYPE))
.ForMember(x => x.Language, opts => opts.MapFrom(x => x.PRODUCT_LANGUAGE))
.ForMember(x => x.Description, opts => opts.MapFrom(x => x.BRIEF_DESC));
});
}
Then in my Global.asax
in the Application_Start()
method I have this line:
AutoMapperConfig.Initialize();
I am trying to use this in my controller like this:
var searchResults = Mapper.Map<List<Shop>, SearchViewModel>(shopList);
After I hit that line it throws that exception. I'm not sure why since I have created maps for all of those properties.