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.
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
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.
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):
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.
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):
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With