title: Initializing and seeding Identity's DbContext in App_Start
body: <p>I'm using the latest MVC, Identity, EntityFramework, as well as the official <a href="https://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples/2.1.0-alpha1">Identity sample solution</a>.</p>
  
  <p>There are lots of ways to run a database initializer in the <code>App_Start()</code>, (e.g. (<code>DropCreateDatabaseIfModelChanges</code>, <code>DropCreateDatabaseAlways</code>).</p>
  
  <p>I tried:</p>
  
  <pre><code>AppDbContext.Instance.Database.Initialize(true); // Instance is static builder 
  </code></pre>
  
  <p>Problem is that with Identity/OWIN, the seeding function pulls manager objects out of the OWIN context (via <code>HttpContext.Current.GetOwinContext()</code>), which apparently, doesn't exist that early in the lifecycle.</p>
  
  <pre><code>var userManager = HttpContext.Current.GetOwinContext().GetUserManager&lt;UserManager&gt;();
  var roleManager = HttpContext.Current.GetOwinContext().Get&lt;RoleManager&gt;();
  </code></pre>
  
  <p>So I get:</p>
  
  <p><code>InvalidOperationException: No owin.Environment item was found in the context.</code></p>
  
  <p>The OWIN context is setup properly, and runs as expected. It's only if I try access it in <code>App_Start</code> that I get this problem.</p>
  
  <p>Initializing the db in <code>App_Start</code> is not strictly necessary, but I prefer explicit code, and want various init routines in there, including creation/seeding of the db. How do I do that?</p>