title: change OwinContext dbContext on runtime
body: <p>I need to run-time change the <code>dbContext</code> for <code>Request.GetOwinContext()</code> to use a specific <code>connectionString</code> but  it's not working.</p>
  
  <p>I've a <code>dbContex</code> <code>class</code> to accept a default <code>connectionString</code> from <code>Web.Config</code> or a specified one like this:</p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public ApplicationDbContext()
          : base("AuthEntities", throwIfV1Schema: false)
      {
          Configuration.ProxyCreationEnabled = false;
          Configuration.LazyLoadingEnabled = false;
      }
  
      public ApplicationDbContext(string sConnectionString)
          : base(sConnectionString, throwIfV1Schema: false)
      {
          Configuration.ProxyCreationEnabled = false;
          Configuration.LazyLoadingEnabled = false;
      }
  
      public static ApplicationDbContext Create()
      {
          return new ApplicationDbContext();
      }
  
      public static ApplicationDbContext Create(string sConnectionString)
      {
          ApplicationDbContext test = new ApplicationDbContext(sConnectionString);
          return test;
      }
  
  }
  </code></pre>
  
  <p>then when a new user is registering i've tried to change the Owin's default dbContext for one with a new connectionString like this:</p>
  
  <pre><code>[AllowAnonymous]
  [Route("create")]
  public async Task&lt;IHttpActionResult&gt; CreateUser(CreateUserBindingModel createUserModel)
  {
       (...)
  
       //get the specific connectionString
       var connectionString = cService.GetCompanyConnectionString(createUserModel.Company);
  
       //generate new dbContext
       var appDbContext = ApplicationDbContext.Create(connectionString);
  
       //get OwinContext
       var context = HttpContext.Current.GetOwinContext();
  
       //replace the DbContext inside OwinContext
       context.Set&lt;ApplicationDbContext&gt;("ApplicationDbContext", appDbContext);
  
       (...)
  }
  </code></pre>
  
  <p>until and including <code>appDbContext</code> everything works as expected but on debuging, after setting <code>context.Set&lt;ApplicationDbContext&gt;...</code> the <code>context</code> is still using the default one.</p>
  
  <p>I've also tried using <code>var context = Request.GetOwinContext();</code> and setting directly as <code>HttpContext.Current.GetOwinContext().Set&lt;ApplicationDbContext&gt;("ApplicationDbContext", appDbContext);</code> and <code>Request.GetOwinContext().Set&lt;ApplicationDbContext&gt;("ApplicationDbContext", appDbContext);</code> but I always get the same result.</p>