I've been trying to setup AutoMapper to instantiate all objects via Ninject. I've got the following code in my global.asax file
Mapper.Configuration.ConstructServicesUsing(x => kernel.Get(x));
And as an example I have the following mapping
Mapper.CreateMap<TestModel, IndexViewModel>();
However, this does not appear to be working. I get an error that 'IndexViewModel' does not have a default constructor.
I can get the mapper to work by explicitly telling automapper to use ninject in the mapping.
Mapper.CreateMap<TestModel, IndexViewModel>().ConstructUsingServiceLocator();
However, I'd rather not have to do this for every single mapping. Am I missing something?