AddAutoMapper() no longer works in new extensions Version

61 views
Skip to first unread message

nanopp

unread,
Jan 3, 2017, 12:35:15 PM1/3/17
to AutoMapper-users
I currently have this code:

        /// <summary>
       
///     Add auto-mapping DI.
       
/// </summary>
       
/// <param name="thisServiceCollection"></param>
       
/// <param name="mapperProfile">Class that contains the EF-DTO specific mappings.</param>
       
/// <returns></returns>
       
public static IServiceCollection AddMappingServices(this IServiceCollection thisServiceCollection,
                                                           
Profile mapperProfile)
       
{
            thisServiceCollection
.AddAutoMapper();

           
var mapperconfig = new MapperConfiguration(cfg => { cfg.AddProfile(mapperProfile); });

           
return thisServiceCollection.AddSingleton(sp => mapperconfig.CreateMapper());
       
}



If I update "AutoMapper.Extensions.Microsoft.DependencyInjection" from "1.1.2" to "1.2.0" I get an exception because of the empty "AddAutoMapper()" initializer.

Please help on how to upgrade!!

Jimmy Bogard

unread,
Jan 3, 2017, 12:42:53 PM1/3/17
to automapper-users
Remove the last two lines altogether. AddAutoMapper does everything you need. Also this might be good to log as a github issue in the AutoMapper.Extensions... repository.

--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages