Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automapper.Mapper.CreateMap cannot be resolved

Tags:

c#

automapper

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

like image 780
Daniel Gustafsson Avatar asked May 19 '15 12:05

Daniel Gustafsson


People also ask

How do I create a map in automapper?

The CreateMap Method. All mapping definitions for AutoMapper are created using the CreateMap method. This is actually and generic method that takes two class types in the form of: AutoMapper.Mapper.CreateMap<SourceClass, DestinationClass> (); It's important to note that this is a one-way mapping.

What happened to the createmap method?

Thanks The static version of the CreateMap method was deprecated in 4.2, then removed from the API in version 5.0. Jimmy Bogard talks about this in more detail in this blog post. The new technique for mapping is non-static, like this (code is from the post):

How to register auto mapper in services container in Java?

We need to register auto mapper in services container in startup class, we can register this service using the AddAutomapper method which allows us to input a set of assemblies It automatically scans for Mappingprofile contain mapping configuration, it’s a nice way to add a mapping configuration.

Does automapper support value resolvers and value converters?

Also, check this blog. AutoMapper supports the ability to construct Custom Value Resolvers, Custom Type Converters, and Value Converters using static service location: Or dynamic service location, to be used in the case of instance-based containers (including child/nested containers):


1 Answers

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.

like image 159
hazzik Avatar answered Sep 29 '22 06:09

hazzik