title: Value cannot be null - Application Manager
body: <p>I was changing some things on a new startup file of a ASP.NET MVC site and I'm getting a null error: </p>
  
  <blockquote>
    <p>System.ArgumentNullException: Value cannot be null. Parameter name:
    context</p>
  </blockquote>
  
  <p>IdentityConfig file:</p>
  
  <p>using -</p>
  
  <pre><code>using Microsoft.AspNet.Identity.Owin;
  using Microsoft.AspNet.Identity;
  </code></pre>
  
  <p>...snip...</p>
  
  <pre><code>public static ApplicationUserManager Create(IdentityFactoryOptions&lt;ApplicationUserManager&gt; options, IOwinContext context) 
  {
      var manager = new ApplicationUserManager(new UserStore&lt;ApplicationUser&gt;(context.Get&lt;IdentityDb&gt;()));
      // Configure validation logic for usernames
      manager.UserValidator = new UserValidator&lt;ApplicationUser&gt;(manager)
      {
          AllowOnlyAlphanumericUserNames = false,
          RequireUniqueEmail = true
      };
  </code></pre>
  
  <p>IdentityDb file : </p>
  
  <pre><code>public class IdentityDb : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public IdentityDb()
          : base("DefaultConnection")
      {
      }
  }
  </code></pre>
  
  <p>I don't know if I am missing something with Microsoft.AspNet.Identity.Owin.IdentityFactoryProvider?</p>
  
  <pre><code>Server Error in '/' Application.
  </code></pre>
  
  <p>Value cannot be null.
  Parameter name: context</p>
  
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
  
  <p>Exception Details: System.ArgumentNullException: Value cannot be null.</p>
  
  <h2>Parameter name: context</h2>
  
  <p>Full Stack Trace :</p>
  
  <pre><code>Source Error: 
  
  
  Line 40:         public static ApplicationUserManager Create(IdentityFactoryOptions&lt;ApplicationUserManager&gt; options, IOwinContext context)
  Line 41:         {
  Line 42:             var manager = new ApplicationUserManager(new UserStore&lt;ApplicationUser&gt;(context.Get&lt;IdentityDb&gt;()));
  Line 43:             // Configure validation logic for usernames
  Line 44:             manager.UserValidator = new UserValidator&lt;ApplicationUser&gt;(manager)
  
  Source File: c:\users\aindriu\documents\visual studio 2015\Projects\Books\Books.Web\App_Start\IdentityConfig.cs    Line: 42 
  
  Stack Trace: 
  
  
  [ArgumentNullException: Value cannot be null.
  Parameter name: context]
     Microsoft.AspNet.Identity.EntityFramework.UserStore`6..ctor(DbContext context) +335
     Microsoft.AspNet.Identity.EntityFramework.UserStore`1..ctor(DbContext context) +5
     Books.Web.ApplicationUserManager.Create(IdentityFactoryOptions`1 options, IOwinContext context) in c:\users\aindriu\documents\visual studio 2015\Projects\Books\Books.Web\App_Start\IdentityConfig.cs:42
     Microsoft.AspNet.Identity.Owin.IdentityFactoryProvider`1.Create(IdentityFactoryOptions`1 options, IOwinContext context) +14
     Microsoft.AspNet.Identity.Owin.&lt;Invoke&gt;d__0.MoveNext() +104
     System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
     System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
     Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.&lt;RunApp&gt;d__5.MoveNext() +187
     System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
     System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
     Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.&lt;DoFinalWork&gt;d__2.MoveNext() +185
     Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69
     Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64
     System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155
  </code></pre>