User.IsInRole returns nothing in ASP.NET Core (Repository Pattern implemented)
<p>I have an ASP.NET Core (Full .NET Framework) application with the following configuration:</p>

<p>Startup.cs</p>

<pre><code>public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

    services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;(p =&gt; {
        p.Password.RequireDigit = true;
        p.Password.RequireNonAlphanumeric = false;
        p.Password.RequireUppercase = true;
        p.Password.RequiredLength = 5;
    })
    .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
    .AddDefaultTokenProviders();

    services.AddMvc();

    // Add application services.
    services.AddTransient&lt;IEmailSender, AuthMessageSender&gt;();
    services.AddTransient&lt;ISmsSender, AuthMessageSender&gt;();
    services.AddTransient&lt;IDbFactory, DbFactory&gt;();
    services.AddTransient&lt;IUnitOfWork, UnitOfWork&gt;();

    services.AddTransient&lt;IUserRepository, UserRepository&gt;();
    services.AddTransient&lt;IUserService, UserService&gt;();
}
</code></pre>

<p>The ApplicationUser extends from IdentityUser and ApplicationDbContext extends IdentityDbContext</p>

<pre><code>public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
{
    public ApplicationDbContext()
        : base()
    {
    }

    public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
        : base(options)
    {
    }

    public virtual void Commit()
    {
        base.SaveChanges();
    }

    protected override void OnConfiguring(DbContextOptionsBuilder builder)
    {
        base.OnConfiguring(builder);

        builder.UseSqlServer("connection string here");
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        // Customize the ASP.NET Identity model and override the defaults if needed.
        // For example, you can rename the ASP.NET Identity table names and more.
        // Add your customizations after calling base.OnModelCreating(builder);

        // Configure model
        // Identity
        new Configuration.Identity.ApplicationUserConfiguration(builder.Entity&lt;ApplicationUser&gt;());
        new Configuration.Identity.ApplicationUserProfileConfiguration(builder.Entity&lt;ApplicationUserProfile&gt;());
        new Configuration.Identity.RoleConfiguration(builder.Entity&lt;IdentityRole&gt;());
        new Configuration.Identity.RoleClaimConfiguration(builder.Entity&lt;IdentityRoleClaim&lt;string&gt;&gt;());
        new Configuration.Identity.ApplicationUserRoleConfiguration(builder.Entity&lt;IdentityUserRole&lt;string&gt;&gt;());
        new Configuration.Identity.ApplicationUserClaimConfiguration(builder.Entity&lt;IdentityUserClaim&lt;string&gt;&gt;());
        new Configuration.Identity.ApplicationUserLoginConfiguration(builder.Entity&lt;IdentityUserLogin&lt;string&gt;&gt;());
        new Configuration.Identity.ApplicationUserTokenConfiguration(builder.Entity&lt;IdentityUserToken&lt;string&gt;&gt;());
    }
}
</code></pre>

<p>Here is my demo data:</p>

<p>Role table</p>

<p><a href="https://i.stack.imgur.com/6zonl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6zonl.png" alt="Role table"></a></p>

<p>User table</p>

<p><a href="https://i.stack.imgur.com/FyzHX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FyzHX.png" alt="User table"></a></p>

<p>UserRole table</p>

<p><a href="https://i.stack.imgur.com/WlLSP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WlLSP.png" alt="UserRole table"></a></p>

<p>In my Login Action i have the following:</p>

<pre><code>[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task&lt;IActionResult&gt; Login(LoginViewModel model, string returnUrl = null)
{
    ViewData["ReturnUrl"] = returnUrl;
    if (ModelState.IsValid)
    {
        // This doesn't count login failures towards account lockout
        // To enable password failures to trigger account lockout, set lockoutOnFailure: true
        var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, model.RememberMe, lockoutOnFailure: false);
        if (result.Succeeded)
        {
            if (User.IsInRole("Admin"))
            {
                return RedirectToAction("Index", "Home", new { area = "Admin" });
            }
            return RedirectToAction("Index", "Home");
        }
        if (result.RequiresTwoFactor)
        {
            return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
        }
        if (result.IsLockedOut)
        {
            _logger.LogWarning(2, "User account locked out.");
            return View("Lockout");
        }
        else
        {
            ModelState.AddModelError(string.Empty, "Invalid login attempt.");
            return View(model);
        }
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}
</code></pre>

<p>What i want to achieve is to redirect the user to a certain area after login.</p>

<p>The current problem i'm facing is that the function <code>User.IsInRole("Admin")</code> returns false and in debug mode, if i look at the usermanager, the current user doesn't have the roles loaded (Count = 0).</p>

<p>Any thoughts would be appreciated.</p>

<p><strong>Update 1</strong></p>

<p>Ignore the Role Id cause is wrong. In fact the user is mapped with the correct value.</p>