title: What is the best practice for using Unity Mvc and Entity Framework?
body: <ul>
  <li>What is the best practice to instantiate my DbContext?</li>
  </ul>
  
  <p>I see some people creating an empty interface for the DbContext like this:</p>
  
  <pre><code>public interface IEasyDayContext : IDisposable { }
  </code></pre>
  
  <p>and then register it in Unity like this (UnityConfig.cs):</p>
  
  <pre><code>container.RegisterType&lt;IEasyDayContext, EasyDayContext&gt;();
  </code></pre>
  
  <p>I see others using the DbContext as an "interface":</p>
  
  <pre><code>container.RegisterType&lt;DbContext, EasyDayContext&gt;();
  </code></pre>
  
  <p>I see other people just instantiating the DbContext in the constructor of the service.</p>
  
  <ul>
  <li><p>I am finding it hard to get updated documentation on Unity Mvc, should I even use it today? </p></li>
  <li><p>How do I setup Unity Mvc?</p></li>
  </ul>
  
  <p>Current documentation (from <a href="https://code.msdn.microsoft.com/Dependency-Injection-in-11d54863" rel="nofollow noreferrer">https://code.msdn.microsoft.com/Dependency-Injection-in-11d54863</a>) suggests that I should put this line of code in my Global.asax.cs file:</p>
  
  <pre><code>UnityConfig.RegisterComponents(); 
  </code></pre>
  
  <p>However, this method doesn't exist anymore. Should I use this instead?</p>
  
  <pre><code>UnityConfig.RegisterTypes(UnityConfig.Container);
  </code></pre>
  
  <ul>
  <li>Should I use PerRequestLifetimeManager?</li>
  </ul>
  
  <p>I am using</p>
  
  <pre><code>AspNet.Mvc 5.2.6
  Unity.Mvc 5.0.15
  Unity.Container 5.8.10
  </code></pre>