title: How to add AutoMapper to DI in .Net core 2.0 Console Application
body: <p>I try to use <a href="https://www.nuget.org/packages/AutoMapper/6.2.2" rel="nofollow noreferrer">AutoMapper</a> in my .Net Core 2.0 Console Application. My class looks like this:</p>
  
  <pre><code>public class AutoGetCurrency
  {
      private readonly IMapper mapper;
      public AutoGetCurrency(IMapper mapper) {
      this.mapper = mapper;
      }
      ....
  }
  </code></pre>
  
  <p>I tried to add services into <strong>Main</strong> method:</p>
  
  <pre><code>static void Main(string[] args)
  {
      var services = new ServiceCollection();
      ServiceProvider = services.BuildServiceProvider();
      services.AddTransient&lt;IMapper&gt;();
      ....
  }
  </code></pre>
  
  <p>But I have the next error <em>'One or more errors occurred. (Object reference not set to an instance of an object.)'</em></p>
  
  <p>Please tell me how to add AutoMapper to use DI.</p>