Bart Schelkens Bart Schelkens - 1 year ago 197
C# Question

Automapper Map.CreateMap not used anymore?

I'm using version of AutoMapper.
Previously I was able to the following:

Mapper.CreateMap<SchoolYearDetail, SchoolYearDto>();

But in the version it doesn't exist anymore.
Can anyone tell me what to do?

Answer Source

Previously AutoMapper was static as per your example, it now wants to be instantiated.

Link below is by the creator of AutoMapper

Here is a snippet if that link stops working.

var config = new MapperConfiguration(cfg => {
  cfg.CreateMap<Source, Dest>();

IMapper mapper = config.CreateMapper();
var source = new Source();
var dest = mapper.Map<Source, Dest>(source);

Plenty of other stackoverflow posts related to this:

Automapper says Mapper.Map is obsolete, global mappings?

AutoMapper Migrating from static API

Hope that helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download