What is the difference between IdentityDbContext and IdentityDbContext in MVC5


On what basis should one decide to use IdentityDbContext versus IdentityDbContext<ApplicationUser> in an ASP.NET MVC5 application?

What benefits do we get by using IdentityDbContext<ApplicationUser> instead of the non-generic IdentityDbContext?

Accepted Answer

IdentityDbContext<ApplicationUser> will let you use your own ApplicationUser class as the User entity. I.e. you can have custom properties on your users. The IdentityDbContext class inherits from IdentityDbContext<IdentityUser> which means you will have to use the IdentityUser class for your users.

If you want to have more properties on your user objects than the few properties that IdentityUser provide (UserName, PasswordHash and a few more) then you may want to choose IdentityDbContext<ApplicationUser>

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why