システム内のすべてのユーザーのリストを生成しようとしています。デフォルトの組み込み認証を使用しています。
ここに私のアイデンティティモデルクラスがあります:
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: コントローラーで正しいデータベース コンテキストを使用していますか?
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]' 型です。