title: Automapper - Error mapping types. Mapping types: IEnumerable`1 -> IEnumerable`1 System.Collections.Generic.IEnumerable`1[[TicketTO, app.DTO
body: <p>I have an <code>ASP.Net Core C#</code> application &amp; using <code>AutoMapper</code></p>
  
  <p>DTO</p>
  
  <pre><code>public class MovieTO
  {
     public int Id { get; set;}
  
     public IEnumerable&lt;TicketTO&gt; Tickets { get; set;}
  }
  
  
  public class TicketTO
  {
     public string Prop1{ get; set;}
     public string Prop2{ get; set;}
     public string Prop3{ get; set;}
     public string Prop4{ get; set;}
  }
  </code></pre>
  
  <p>Domain Entity</p>
  
  <pre><code>public class Movie
  {
     public int Id { get; set;}
  
     public IEnumerable&lt;BasicTicket&gt; Tickets { get; set;}
  }
  
   public class BasicTicket
  {
  
  }
  
   public class RegularTicket : BasicTicket
  {
     public string Prop1{ get; set;}
     public string Prop2{ get; set;}
  }
  
   public class SpecialTicket : BasicTicket
  {
     public string Prop3{ get; set;}
     public string Prop4{ get; set;}
  }
  </code></pre>
  
  <p>AutoMapper Configuration</p>
  
  <pre><code> public class AppObjectsMapper
  {
      private readonly IMapper _mapper;
  
      public ObjectsMapper()
      {
          var config = new MapperConfiguration(cfg =&gt;
          {
  
              cfg.CreateMap&lt;TicketTO, RegularTicket&gt;();
              cfg.CreateMap&lt;TicketTO, SpecialTicket&gt;();
  
              cfg.CreateMap&lt;MovieTO, Movie()
  
          });
          _mapper = config.CreateMapper();
      }
  
  
      public Movie MapToEntity(MovieTO movie)
      {
  
          if(movie.IsSpecial)
          {
              //#Line1
              _mapper.Map&lt;IEnumerable&lt;TicketTO&gt;, IEnumerable&lt;SpecialTicket&gt;&gt;(movie.Tickets); 
          }
          else
          {
               //#Line2
              _mapper.Map&lt;IEnumerable&lt;TicketTO&gt;, IEnumerable&lt;RegularTicket&gt;&gt;(movie.Tickets);
          }
          return _mapper.Map&lt;MovieTO, Movie&gt;(eventDetail);
      }
  
         }
  </code></pre>
  
  <p>When the mapper is called at #line1 or #line2, it throws the below run time error.</p>
  
  <blockquote>
    <p>Error mapping types. Mapping types: 
    IEnumerable<code>1 -&gt; IEnumerable</code>1
    System.Collections.Generic.IEnumerable<code>1[[TicketTO, app.DTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -&gt; 
    System.Collections.Generic.IEnumerable</code>1[[Domain.SpecialTicket, myapp.domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]</p>
  </blockquote>
  
  <p>How to typecast/map this ?</p>
  
  <p>Thanks!</p>