I am using ProjectTo function of AutoMapper 5.2.0 in asp.net core. I have already initialized my mappings at startup class. But it is throwing exception : Mapping not initialized.
            Asked
            
        
        
            Active
            
        
            Viewed 1,404 times
        
    2 Answers
0
            
            
        Initialize Map in startup.cs
Mapper.Initialize(config => {
    config.CreateMap<source, Destination>().ReverseMap();      
});
        Sᴀᴍ Onᴇᴌᴀ
        
- 8,218
 - 8
 - 36
 - 58
 
        lazydeveloper
        
- 891
 - 10
 - 20
 
0
            
            
        You are missing the initialization, however, I would recommend you to use the configuration by profile approach especially if you are interested in testing you code.
Could you please add more details to the question?
This is a typical configuration with static methods
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        ...
        AutoMapper.Mapper.Initialize(cfg =>
        {
            cfg.CreateMap<ClassEntity, ClassDto>().ReverseMap();
        });
         ...
    }
        Henry
        
- 785
 - 9
 - 17
 
- 
                    please add more details in your answer – Alexan Jul 23 '17 at 20:42