title: Unsupported Mapping .NET 5 using AutoMapper
body: <p>I have an profile mapping file.</p>
  <pre><code>public class AutoMapperProfiles : Profile
      {
          public AutoMapperProfiles()
          {
              #region MyFunObjects
              CreateMap&lt;CreateMyFunObjectDto, MyFunObject&gt;();
              CreateMap&lt;MyFunObject, MyFunObjectDetailDto&gt;();
              #endregion
          }
      }
  </code></pre>
  <p><code>MyFunObject</code> Model is simple:</p>
  <pre><code> public class MyFunObject 
      {
          [Key]
          public int Id { get; set; }
          public string Name { get; set; }
      }
  </code></pre>
  <p>My dto's are simple:</p>
  <pre><code> public class CreateMyFunObjectDto
      {
          [Required]
          public string Name { get; set; }
      }
  
   public class MyFunObjectDetailDto
      {
          public int Id { get; set; }
          public string Name { get; set; }
      }
  </code></pre>
  <p>Automapper is registered in <code>ConfigureServices</code> of <code>Startup.cs</code></p>
  <pre><code>services.AddAutoMapper(typeof(Startup));
  </code></pre>
  <p>And in my service, this line breaks and throws an unhandled error &quot;Unsupported Mappings&quot;.</p>
  <pre><code> MyFunObject myFunObject = _mapper.Map&lt;CreateMyFunObjectDto, MyFunObject &gt;(createMyFunObjectDto);
  </code></pre>
  <p>this also fails in another method call.</p>
  <pre><code>return _mapper.Map&lt;List&lt;MyFunObjectDetailDto&gt;&gt;(myFunObjectList);
  </code></pre>
  <p>What am I missing?</p>
  <p>Stack trace:</p>
  <pre><code>blazor.server.js:19 [2021-01-30T15:26:00.306Z] Error: AutoMapper.AutoMapperMappingException: Error mapping types.
  
  Mapping types:
  Object -&gt; List`1
  System.Object -&gt; System.Collections.Generic.List`1[[Ruak_Models.DTOs.StatusDtos.StatusDetailDto, Ruak_Models, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
   ---&gt; AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
  
  Mapping types:
  Status -&gt; StatusDetailDto
  Ruak_Data.Models.Status -&gt; Ruak_Models.DTOs.StatusDtos.StatusDetailDto
     at lambda_method90(Closure , Status , StatusDetailDto , ResolutionContext )
     at lambda_method89(Closure , Object , List`1 , ResolutionContext )
     --- End of inner exception stack trace ---
     at lambda_method89(Closure , Object , List`1 , ResolutionContext )
     at Ruak_Business.Services.StatusService.StatusService.GetStatuses() in C:\Code\BlazorRuak\RuakBlazor\Ruak\Ruak_Business\Services\StatusService\StatusService.cs:line 53
     at Ruak_Server.Pages.Objectives.ObjectiveList.OnInitializedAsync() in C:\Code\BlazorRuak\RuakBlazor\Ruak\Ruak_Server\Pages\Objectives\ObjectiveList.razor.cs:line 28
     at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
  </code></pre>