Often it is useful to be able to load all of the profiles in one or more assemblies into a configuration. AutoMapper provides the method AddProfiles
method, which has several overloads that allow profiles to be loaded by passing the Assembly, specifying the assembly name, or specifying a type contained in the assembly. Only classes inheriting from AutoMapper.Profile will be located and added to the configuration.
Load all profiles in an assembly by specifying the name of the assembly:
Mapper.Initialize(cfg => {
cfg.AddProfiles("MyApplication.Core", "MyApplication.Web");
});
Load all profiles in an assembly by specifying a type from the assembly:
Mapper.Initialize(cfg => {
cfg.AddProfiles(typeof(Student), typeof(Course));
});
Load all profiles in the current assembly:
Mapper.Initialize(cfg => {
cfg.AddProfiles(Assembly.GetExecutingAssembly());
});