Reputation: 30813
Is there any way to get the number of users in the AspNetUsers
table which is automatically created by the ASP.Net
MVC 5
?
In the ApplicationDbContext
which is created automatically in the IdentityModels.cs
file when you start a ASP.Net MVC 5
project, I do not see something like:
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
which is a typical way of representing and getting the entries in the database's table for a certain connection.
Upvotes: 3
Views: 502
Reputation: 119146
Your context is using Identity (probably v2) which means it inherits from IdentityDbContext
, that is where you will see the users DbSet
. So you should be able to write something like this:
var userCount = context.Users.Count();
Upvotes: 3