title: How do I inject dependencies into a model?
body: <p>Typically, an action method will end with something like this:</p>
  
  <pre><code>return View(new Model());
  </code></pre>
  
  <p>But if my model is going to have services injected, it won't have a default ctor.  So it would have to look like this:</p>
  
  <pre><code>return View(new Model(new Service());
  </code></pre>
  
  <p>But if the service has dependencies it'd be more like this:</p>
  
  <pre><code>return View(new Model(new Service(new Repository())));
  </code></pre>
  
  <p>...which starts to get ridiculous.  Isn't this what a IoC container is for?  So I'd be tempted to write something more like this:</p>
  
  <pre><code>return View(container.Resolve&lt;IModel&gt;());
  </code></pre>
  
  <p>but in order to get <code>container</code> it would have to be injected into my controller, and I hear that <a href="https://stackoverflow.com/questions/10356497/is-is-an-anti-pattern-to-inject-di-container-to-almost-each-class">injecting the container itself is an anti-pattern</a>.</p>
  
  <p>So what is the right way?  How do I pass my dependencies to my model when I return the view from the action method?</p>