title: DbContext not updating but DB is
body: <p>I have an MVC 5 data first app that I've been helping with. I made it use a filter to determine if the AD user is allowed certain functionality (via decorating methods/classes). </p>
  
  <p>However, after changing a user's info in the db, the filter's context still has the old info for that user. The user 'edit' page keeps correct info though. Strange. This is happening just in the filter, not in any controller.</p>
  
  <p>Here's the filter:</p>
  
  <pre><code>protected override bool AuthorizeCore(HttpContextBase httpContext)
  {
      if (!base.AuthorizeCore(httpContext)) return false;
  
      // Get the groups for this authorization (from the decoration attribute)
      var groups = Groups.Split(',').ToList();
  
      var userDisplayName = string.Empty;
  
      using (HostingEnvironment.Impersonate())
      {
          // Verify that the user is in the given AD group (if any)
          var context = new PrincipalContext(
              ContextType.Domain);
  
          var userPrincipal = UserPrincipal.FindByIdentity(
              context,
              IdentityType.SamAccountName,
              httpContext.User.Identity.Name);
  
          userDisplayName = userPrincipal.DisplayName;
      }
  
      // check for UserRoles for this 
      var user = _varDB.Users.FirstOrDefault(x =&gt; x.UserName == userDisplayName); //&lt; Here is where it gets stale info...
      IList&lt;UserRole&gt; usersRoles = new List&lt;UserRole&gt;();
      if (user != null)
      {
          usersRoles = user.UserRoles.ToList();
      }
  
      // determine if the user is allowed to see this controller/page
      foreach (var ur in usersRoles)
      {
          if (groups.Contains(ur.RoleName))
          {
              return true;
          }
      }
  
      return false;
  }
  </code></pre>
  
  <p>On the UserController, if I manually change the db, and refresh the page, I see the changes. But in this filter, if I change the data, it never changes until I recycle the app pool.</p>
  
  <p>fyi, the top of the class goes like this:</p>
  
  <pre><code>public class AuthorizeByDbRoleAttribute : AuthorizeAttribute
  {       
      private static ExtVariablesEntities _varDB = new ExtVariablesEntities();
  }
  </code></pre>
  
  <p>If this filter doesn't get the updated user info, it can't keep users out of or let them use functionality if changed and the app pool isn't recycled.</p>