AutoMapper extensions for Microsoft DI 3.2.0 released
Today I pushed out a small change to the AutoMapper.Extensions.Microsoft.DependencyInjection package to allow instance-based initialization. Before you initialize with services.AddAutoMapper()
, set a configuration flag:
ServiceCollectionExtensions.UseStaticRegistration = false;
services.AddAutoMapper();
By default the extension will register using Mapper.Initialize
, but with this flag off, the extension instead registers an instance.
Mapper.Initialize
is enforced to only be called once, which can be an issue for unit tests that set up the service collection many times.
Enjoy!