public ActionResult Register(UserVM userVM) { if (_dbContext.Users.Any(z => z.Email == userVM.Email)) { TempData["EmailExists"] = "EmailNotValid"; return(RedirectToAction("Register")); } if (ModelState.IsValid) { var result = authBLL.RegisterUser(userVM); if (result > 0) { return(RedirectToAction("Index")); } } var roles = _dbContext.Roles.Select(x => new RoleVM { RoleID = x.RoleID, RoleName = x.RoleName }).ToList(); SelectList _stackHolderTypes = new SelectList(roles, "RoleID", "RoleName"); ViewBag.FarmerSID = _stackHolderTypes; //var roles = _dbContext.Roles.ToList(); //SelectList _stackHolderTypes = new SelectList(roles, "ID", "RoleName"); //ViewBag.FarmerSID = _stackHolderTypes; return(View(userVM)); }