title: Why does a role shows as "not exist" even when present in the database (asp.net mvc)
body: <p>I'm trying to add users to a role when registering a user so i seeded the roles and updated the database with the code below in the migrations.cs class</p>
  
  <pre><code>        var RoleManager = new RoleManager&lt;IdentityRole&gt;(new RoleStore&lt;IdentityRole&gt;(context));
          string[] roleNames = { "Admin", "Reviewer", "User" };
          IdentityResult roleResult;
          foreach (var roleName in roleNames)
          {
              if (!RoleManager.RoleExists(roleName))
              {
                  roleResult = RoleManager.Create(new IdentityRole(roleName));
              }
          }
  </code></pre>
  
  <p>i tried to fetch the roleNames into a dropdownlist in my accountcontroller class</p>
  
  <pre><code>public ActionResult Register()
  {
      var model = new RegisterViewModel();
          model.RolesList = new SelectList(_db.Roles, "Id", "Name");
  
      return View(model);
  }
  
  //
  // POST: /Account/Register
  [HttpPost]
  [AllowAnonymous]
  [ValidateAntiForgeryToken]
  public async Task&lt;ActionResult&gt; Register(RegisterViewModel model)
  {
      if (ModelState.IsValid)
      {
          var user = new ApplicationUser()
          {
              UserName = model.UserName,
              PortalUser = new PortalUser()
              {
                  Email = model.Email,
                  UserName = model.UserName
              }
          };
          var result = await UserManager.CreateAsync(user, model.Password);
          if (result.Succeeded)
          {
              UserManager.AddToRole(user.Id, model.Roleid);                
              return RedirectToAction("Index", "ApplicationReview");
          }
          else
          {
              AddErrors(result);
          }
      }
      model.RolesList = new SelectList(_db.Roles, "Id", "Name");
      // If we got this far, something failed, redisplay form
      return View(model);
  }
  </code></pre>
  
  <p>However the debugger showed an error at this point </p>
  
  <blockquote>
    <p>UserManager.AddToRole(user.Id, model.Roleid);
    Role bec759ac-55ca-40f0-a8b8-00de314dd2b3 does not exist.</p>
  </blockquote>
  
  <p>however this role exist in the database so i'm confused as to what the problem is
  <a href="https://i.stack.imgur.com/1cUKk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1cUKk.png" alt="enter image description here"></a></p>