Simple User Registration Form with Entity Framework Database in ASP.Net MVC

Last Reply 11 days ago By dharmendr

Posted 11 days ago

Hi followed the step in ths example but am getting an error in UsersEntities and User , "could not be found".

public ActionResult UserRegister(User user)
{
UsersEntities usersEntities = new UsersEntities();
usersEntities.Users.Add(user);
usersEntities.SaveChanges();
string message = string.Empty;
switch (user.UserId)
{
case -1:
message = "Username already exists.\\nPlease choose a different username.";
break;
case -2:
message = "Supplied email address has already been used.";
break;
default:
message = "Registration successful.\\nUser Id: " + user.UserId.ToString();
break;
}
ViewBag.Message = message;

return View(user);
}

 

You are viewing reply posted by: dharmendr 11 days ago.