在MVC5中,IdentityDbContext和IdentityDbContext<ApplicationUser>有什么区别?

9

在 ASP.NET MVC5 应用程序中,应该基于什么基础来决定使用 IdentityDbContext 还是 IdentityDbContext<ApplicationUser>

与非泛型的 IdentityDbContext 相比,使用 IdentityDbContext<ApplicationUser> 有哪些好处?


我们如何决定在MVC5应用程序中使用IdentityDbContext还是IdentityDbContext<ApplicationUser>?你想在这里写IdentityDbContext<ApplicationUser>吗?在下一句中提到的利益也是如此吗? - Olav Nybø
感谢 @ChristopherHarris - Sandeep Kumar
1个回答

12
IdentityDbContext<ApplicationUser>将让你使用自己的ApplicationUser类作为User实体,即你可以在用户上有自定义属性。 IdentityDbContext类继承自IdentityDbContext<IdentityUser>,这意味着你必须使用IdentityUser类来表示你的用户。
如果你想要在用户对象上拥有比IdentityUser提供的少量属性(如用户名、密码哈希等)更多的属性,则可以选择IdentityDbContext<ApplicationUser>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接