I'm trying to upgrade to AutoMapper 7.0.1 which no longer uses static methods. I'm getting the following error:
Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.
I think it's coming from profiles like this which I switched to not use static methods except it still uses the static Mapper.Map<>()
in the lambda expression:
public class MyProfile : Profile
{
public MyProfile()
{
CreateMap<CredentialDetailDto, CredentialDetail>()
.ForMember(x => x.Owners, opt => opt.ResolveUsing(y =>
Mapper.Map<IList<OwnerDto>>(y.Owners)))
}
}
How can I get an instance of the mapper to be used in place of the static Mapper.Map
method?