Trying to add AutoMapper to Asp.net Core 2?

后端 未结 10 1659
我在风中等你
我在风中等你 2020-12-23 19:20

I worked on a asp.net core 1.1 project a while ago and use in projetc AutoMapper.

in asp.net core 1.1, I add services.AddAutoMapper() in startup file :<

10条回答
  •  礼貌的吻别
    2020-12-23 19:46

    In new version (6.1) of AutoMapper.Extensions.Microsoft.DependencyInjection nuget package you should use it as follows:

    services.AddAutoMapper(Type assemblyTypeToSearch);
    // OR
    services.AddAutoMapper(params Type[] assemblyTypesToSearch);
    

    e.g:

    services.AddAutoMapper(typeOf(yourClass)); 
    

提交回复
热议问题