2013-07-19 2 views
-1

.... 그리고 사용자보기 (즉에 사용자 ID를 전달) Userroles 컨트롤러엔티티 프레임 워크, 간단한 멤버 자격 공급자를 사용 EntityCommandExecutionExeption

내 색인 (ID는 사용자의 컨트롤러에서보기 ActionLink에서 사용자 ID입니다)

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()); 
    } 

하지만 내 모델이다

[Table("webpages_UsersInRoles")] 
public class UserRoles 
{ 
    [Key] 
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] 
    public int UserId { get; set; } 
    public int RoleID { get; set; } 

} 

오류 enter image description here

,

감사 즉

가, 그것도 UserProfiles_UserID을 lookingfor 수 야해 .....?

[SqlException (0x80131904): Invalid column name 'UserProfiles_UserId'. 
Invalid column name 'UserProfiles_UserId'. 

을 아니다 내 데이터베이스 또는 내 모델은이 필드가/왜 자신이 찾고에 임 혼란 : 스택 추적 :

또한 나는이받을 수 있나요?

+0

당신의 제목이 이해되지 않는다 –

+0

제목이 말을하도록되어, 내가 바로와 문제가 무엇인지? .... – Pakk

답변

1

다음과 같은 코드를 사용하여 역할에 사용자를 추가 할 수 있습니다

System.Web.Security.Roles.AddUsersToRole("user1", "user2", "user3", ... , "yourrolename");