title: How to use AutoMapper in Web Api in .Net Core?
body: <p>Currently, I have this Web Api method which manually map my entity to DTO object and it works without issue. Now, I would like to implement AutoMapper which I have installed in registered in in <code>ConfigureServices</code> method and created the AutoMapper profile class and injected automapper in my Web Api controller constructor.</p>
  
  <p>This is my manual mapping without AutoMapper</p>
  
  <pre><code>[HttpGet]
      public async Task&lt;ActionResult&lt;IEnumerable&lt;MovieDto&gt;&gt;&gt; GetMovies()
      {
          //manual mapping which can be replaced with Automapper
          var movies = (from m in _context.Movies
                        select new MovieDto()
                        {
                            Id = m.Id,
                            MovieTitle = m.MovieTitle,
                            ReleaseDate = m.ReleaseDate,
                            MovieStatus = m.MovieStatus,
                            PhotoFile = m.PhotoFile
                        }).ToListAsync();
  
          return await movies;
  
      }
  </code></pre>
  
  <p>and this is how I tried to add automapper to replace manual mapping.</p>
  
  <pre><code>[HttpGet]
  public async Task&lt;ActionResult&lt;IEnumerable&lt;MovieDto&gt;&gt;&gt; GetMovies()
  {
        return _mapper.Map&lt;IEnumerable&lt;MovieDto&gt;&gt;(_context.Movies);
  }
  </code></pre>
  
  <p>But, it hits error <code>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable&lt;CinemaApp.NETCore31.WebAPI.Models.MovieDto&gt;' to 'Microsoft.AspNetCore.Mvc.ActionResult&lt;System.Collections.Generic.IEnumerable&lt;CinemaApp.NETCore31.WebAPI.Models.MovieDto&gt;&gt;'</code></p>