I am trying to generate a list of all the users in the system. I am using the default built in authentication.
here is my Identity models class:
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")
{
}
}
Now i have creates a controller called users:
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: Am i using the correct databse context in my controller?
2:
What model must i use in my view? Currently I have the following:
@model IEnumerable<User_Manager_Interface.Models.ApplicationDbContext>
But it give me an error when I run it: THe error is as follows:
The model item passed into the dictionary is of type '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]'.