7

I was moving some of my objects that i use automapper for to another project. And suddenly i get the error Cannot Resolve CreateMap in the automapper profile.

enter image description here

I've been searching for a solution for some hours now but i can't find anything. I have reinstalled the automapper nuget but that didn't help

Daniel Gustafsson
  • 1,725
  • 7
  • 37
  • 78

2 Answers2

4

Check that you dont have any objects called "Mapper" in the current or parent namespaces.

Try to use full qualified name for Mapper, like this:

AutoMapper.Mapper.CreateMap<Address, AddressDTO>();

If this does not help, try to clear ReSharper's cache (if you are using R#), then restart visual studio.

hazzik
  • 13,019
  • 9
  • 47
  • 86
1

If you're using latest version you can create map like following:

Mapper.Initialize(cfg => {
    cfg.CreateMap<Address, AddressDTO>();
    //cfg.CreateMap<Customer, RegisterViewModel>();
});
HasanG
  • 12,734
  • 29
  • 100
  • 154