Daniel Gustafsson
Daniel Gustafsson

Reputation: 1825

Automapper.Mapper.CreateMap cannot be resolved

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

Upvotes: 7

Views: 4513

Answers (2)

HasanG
HasanG

Reputation: 13171

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

Mapper.Initialize(cfg => {
    cfg.CreateMap<Address, AddressDTO>();
    //cfg.CreateMap<Customer, RegisterViewModel>();
});

Upvotes: 1

hazzik
hazzik

Reputation: 13374

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.

Upvotes: 4

Related Questions