title: How inject service in AutoMapper profile class
body: <p>I need to use a service layer in the <code>AutoMapper</code> profile class in <code>ASP.NET Core</code> but when I inject service in the constructor it does not work. For example:</p>
  
  <pre><code>public class UserProfile : Profile
  {
      private readonly IUserManager _userManager;
  
      public UserProfile(IUserManager userManager)
      {
          _userManager = userManager;
  
          CreateMap&lt;User, UserViewModel&gt;()
             .ForMember(dest =&gt; dest.FullName, opt =&gt; opt.MapFrom(src =&gt; $"{src.FirstName} {src.LastName}"));
      }
  }
  </code></pre>
  
  <p>And in <code>Startup</code> Class:</p>
  
  <pre><code> public class Startup
  {
      public IConfigurationRoot Configuration { set; get; }
  
      public Startup(IHostingEnvironment env)
      {
         //some code
      }
  
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddSingleton&lt;IActionContextAccessor, ActionContextAccessor&gt;();
          services.AddMvc();
          services.AddScoped&lt;IUsersPhotoService, UsersPhotoService&gt;();
          services.AddAutoMapper(typeof(UserProfile));
      }
  }
  </code></pre>
  
  <p>How do to do it?</p>