Asp.net

MVC5 中的 IdentityDbContext 和 IdentityDbContext<ApplicationUser> 有什麼區別

  • November 29, 2013

應該在什麼基礎上決定在 ASP.NET MVC5 應用程序中使用IdentityDbContext與使用?IdentityDbContext&lt;ApplicationUser&gt;

IdentityDbContext&lt;ApplicationUser&gt;通過使用而不是非泛型我們可以獲得什麼好處IdentityDbContext

IdentityDbContext&lt;ApplicationUser&gt;將讓您使用自己的ApplicationUser類作為User實體。即您可以在您的使用者上擁有自定義屬性。該類IdentityDbContext繼承自IdentityDbContext&lt;IdentityUser&gt;這意味著您必須IdentityUser為您的使用者使用該類。

如果您想在使用者對像上擁有比IdentityUser提供的少數屬性(UserName、PasswordHash 等)更多的屬性,那麼您可能需要選擇IdentityDbContext&lt;ApplicationUser&gt;

引用自:https://stackoverflow.com/questions/20281074