title: ASP.NET Identity 2.0 UserManager.FindByIdAsyc not returning Roles
body: <p>I am building a website using ASP.NET MVC v5.2, Entity Framework v6.0 (Code First) and Identity 2.0.</p>
  
  <p>I have the following code in my UserAdmin controller:</p>
  
  <pre><code>    // GET: /UserAdmin/Details/5
      public async Task&lt;ActionResult&gt; Details(string id)
      {
          if (id == null)
          {
              return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
          }
  
          var user = await UserManager.FindByIdAsync(id);
          return View(user);
      }
  </code></pre>
  
  <p>My problem is that while I can populate a user's roles with the UserManager, it is <strong>not picking up the roles associated with that user</strong> when using the FindByIdAsync method.</p>
  
  <p>Here is data from the IdentityUserRole table which shows for the highlighted user assigned to two roles:
  <img src="https://i.stack.imgur.com/h5hH0.jpg" alt="enter image description here"></p>
  
  <p>Here is the debug info showing the same user as above but the Roles count is zero:
  <img src="https://i.stack.imgur.com/8myzl.jpg" alt="enter image description here"></p>
  
  <p>Why are the roles for this user not being returned?</p>
  
  <p><strong>Edit #1</strong>  </p>
  
  <p>I am not using the default implementations for UserManager.  </p>
  
  <p>My ApplicationUser extends IdentityUser to allow me to add custom properties. My ApplicationDbContext extends IdentityDbContext.</p>
  
  <p>Here's where I set up my primary keys for Identity using Fluent API:</p>
  
  <pre><code>        modelBuilder.Entity&lt;IdentityUserLogin&gt;().HasKey&lt;string&gt;(l =&gt; l.UserId);
          modelBuilder.Entity&lt;IdentityRole&gt;().HasKey&lt;string&gt;(r =&gt; r.Id);
          modelBuilder.Entity&lt;IdentityUserRole&gt;().HasKey(r =&gt; new { r.RoleId, r.UserId });
  </code></pre>