我正在嘗試生成系統中所有用戶的列表。我正在使用默認的內置身份驗證。在我的asp mvc視圖中使用什麼模型
,這裏是我的身份識別模型類:
public class ApplicationUser : IdentityUser
{
[Required]
[MaxLength(50)]
public string email { get; set; }
[Required]
[StringLength(11, MinimumLength = 11)]
public string cellNo { get; set; }
[Required]
[MaxLength(50), MinLengthAttribute(3)]
public string firstName { get; set; }
[Required]
[MaxLength(50), MinLengthAttribute(3)]
public string lastName { get; set; }
public DateTime birthdate { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("AuthenticationConnection")
{
}
}
現在我有創建一個控制器進行調用用戶:
public class UsersController : Controller
{
private User_Manager_Interface.Models.ApplicationDbContext userDb = new User_Manager_Interface.Models.ApplicationDbContext();
// GET: /Users/
public ActionResult Index()
{
return View(userDb.Users.ToList());
}
}
1: 我用我在我的控制器正確DATABSE背景?
2: 我認爲我應該使用什麼模型?目前,我有以下幾點: @model IEnumerable<User_Manager_Interface.Models.ApplicationDbContext>
但它給我一個錯誤,當我運行它:錯誤如下:
傳遞到字典的模型產品 型「的System.Collections.Generic.List
1[User_Manager_Interface.Models.ApplicationUser]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1 [User_Manager_Interface.Models.ApplicationDbContext]'。
請檢查綁定到您的視圖的模型以及您傳遞的是哪個模型! –