I have the following AutoMapper profile:
public class AutoMapperBootstrap : Profile { protected override void Configure() { CreateMap<Data.EntityFramework.RssFeed, IRssFeed>().ForMember(x => x.NewsArticles, opt => opt.MapFrom(y => y.RssFeedContent)); CreateMap<IRssFeedContent, Data.EntityFramework.RssFeedContent>().ForMember(x => x.Id, opt => opt.Ignore()); } } And I am initializing it like this:
var config = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperBootstrap()); }); container.RegisterInstance<IMapper>("Mapper", config.CreateMapper()); When I try to inject it in my constructor:
private IMapper _mapper; public RssLocalRepository(IMapper mapper) { _mapper = mapper; } I recieve the following error:
The current type, AutoMapper.IMapper, is an interface and cannot be constructed. Are you missing a type mapping?
How can I initialize the AutoMapper profile properly with Unity, so that I can use the mapper anywhere through DI?