Using Simple Membership provider.... and a User view ( that passes UserID into ) Userroles Controller
My Index ( of UserRoles ) ( the ID is UserID from ActionLink in the View from User Controller)
public ActionResult Index([Bind(Prefix = "id")] int id)
{
var usr = db.UserRoles.Find(id);
if (usr != null)
{
return View(usr);
}
return View();
//return View(db.UserRoles.ToList());
}
But my model is
[Table("webpages_UsersInRoles")]
public class UserRoles
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public int RoleID { get; set; }
}
Error
Thanks
In other words, It shouldnt even be lookingfor UserProfiles_UserID.....?
Also i do get this : Stack Trace:
[SqlException (0x80131904): Invalid column name 'UserProfiles_UserId'.
Invalid column name 'UserProfiles_UserId'.
Nor my Database or my Model have this field in it ;/ im confused on why its looking for it?
You can add a user to a role with the following code:
System.Web.Security.Roles.AddUsersToRole("user1", "user2", "user3", ... , "yourrolename");