title: ASP.NET Core MVC Dependency Injection via property or setter method
body: <p>It has <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection" rel="nofollow noreferrer">been well documented</a>, how to inject dependencies into services.</p>
  
  <p><strong>Question:</strong> But is it (already) possible in ASP.NET Core 2.0 to have the system's DI mechanism <em>automatically</em> inject a service into a method or into a property?</p>
  
  <p>Sidenote: In PHP-Symfony this pattern is called <a href="https://symfony.com/doc/current/service_container/calls.html" rel="nofollow noreferrer">setter injection</a>.</p>
  
  <p><strong>Example:</strong>
  Say I have a common <code>MyBaseController</code> class for all controllers in my project and I want a service (e.g. the UserManager service) to be injected into <code>MyBaseController</code> that can be later accessed in all child controllers. I could use constructor injection to inject the service in the child class and pass it via <code>base(userManager)</code> to the parent. But having to perform this in all child constructors of all controllers is pretty tedious.</p>
  
  <p>So I would like to have a setter in <code>MyBaseController</code> like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public abstract class MyBaseController : Controller
  {
    public UserManager&lt;User&gt; userManager { get; set; }
  
    // system should auto inject UserManager here
    public void setUserManager(UserManager&lt;User&gt; userManager) {
      this.userManager = userManager;
    }
  }
  </code></pre>
  
  <p>...so I don't have to do the following in every child constructor just to pass the dependency to the parent:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class UsersController : MyBaseController
  {
    public ChildController(UserManager&lt;User&gt; userManager) : base(userManager) {}
  </code></pre>
  
  <hr>
  
  <p>Update: The answer given <a href="https://stackoverflow.com/questions/38459625">here</a> is what I want to achieve, however the question was asked for ASP.NET Core 1.0, I'm interested in whether any solutions have been added in ASP.NET Core 2.0.</p>