title: Dependency Injection of type Func<T> in ASP.NET Core
body: <p>I am trying to inject a Func into a webapi controller using asp.net core 2.0.1 for my DataContext.</p>
  
  <p>In my Startup.cs i have added;</p>
  
  <pre><code>services.AddTransient&lt;Func&lt;IDataContext&gt;, Func&lt;DataContext&gt;&gt;();
  </code></pre>
  
  <p>I then in my controller constructor pass this to my service;</p>
  
  <pre><code>private readonly ClientService _service;
  
  public ClientController(Func&lt;IDataContext&gt; context)
  {
       _service = new ClientService(context);
  }
  </code></pre>
  
  <p>However, when I run the program and try to call an endpoint I am getting the error;</p>
  
  <blockquote>
    <p>InvalidOperationException: Unable to resolve service for type &#x27;System.Object&#x27; while attempting to activate &#x27;System.Func`1[Data.EF.DataContext]&#x27;.</p>
  </blockquote>
  
  <p>why is this please? and how can I resolve it.</p>