title: How to use Automapper with ASP.NET Core 2.2 API
body: <p>This is the error I get:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: Unable to resolve service for type 
        'myBackEnd.Entities.Striper' while attempting to activate 
        'myBackEnd.Controllers.StripeController'.
          at 
        Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)</p>
  </blockquote>
  
  <p>I am working on using Automapper for the first time.  I am also new to NET. I am using an HTTPPOST to get data from the front end in the format</p>
  
  <pre><code>    amount :  string;
      currency :  string;
      description :  string;
      token :  string;
      name: string;
      address_city: string;
      address_line1: string;
      address_line2: string;
      address_state: string;
      address_zip: string;
      address_country: string;
  </code></pre>
  
  <p>I have stripe.cs and stripeDto.cs files:</p>
  
  <pre><code>public class Striper
  {
      public object Amount { get; set; }
      public string Currency { get; set; }
      public object Description { get; set; }
      public string Token { get; set; }
      public string Name { get; set; }
      public string Address_line1 { get; set; }
      public string Address_line2 { get; set; }
      public string Address_state { get; set; }
      public string Address_zip { get; set; }
      public string Address_country { get; set; }
  }
  </code></pre>
  
  <p>stripeDto:</p>
  
  <pre><code>public class StripeDto
  {
      public object Amount { get; set; }
      public string Currency { get; set; }
      public object Description { get; set; }
      public string Token { get; set; }
      public string Name { get; set; }
      public string Address_line1 { get; set; }
      public string Address_line2 { get; set; }
      public string Address_state { get; set; }
      public string Address_zip { get; set; }
      public string Address_country { get; set; }
  }
  </code></pre>
  
  <p>This is the mapping profile file:</p>
  
  <pre><code>public class MappingProfile : Profile
  {
      public MappingProfile()
      {
          CreateMap&lt;Striper, StripeDto&gt;();
          CreateMap&lt;StripeDto, Striper&gt;();
      }
  }
  </code></pre>
  
  <p>Finally this is the Controller:</p>
  
  <pre><code>private readonly AppDbContext _context;
  private IMapper _mapper;
  
  public StripeController(AppDbContext context, IMapper mapper)
  {
       _context = context;
       _mapper = mapper;
  }
  
  public async Task&lt;IActionResult&gt; PostCreditCardData([FromBody] StripeDto stripeDto)
  {
          Console.WriteLine("got this from the front end", stripeDto);
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
            _context.StripeDto.Add(stripeDto);
           // Instantiate source object stripe
           await _context.SaveChangesAsync();
  
          _striper = _mapper.Map&lt;Striper&gt;(stripeDto);
          return Ok(_striper);
  
  
   }
  </code></pre>
  
  <p>I get this error in visual studio "Unable to resolve service for type 'myBackEnd.Entities.Striper'"</p>
  
  <p>Here is the startup.cs code:</p>
  
  <pre><code>services.AddAutoMapper();
  </code></pre>