Search code examples
entity-framework-4asp.net-identity

Mapping of AspNetUsers and IdentityUser


Can't understand how the IdentityUser is mapped to AspNetUsers like there is no [Table] attribute above IdentityUser so how EF comes to know the table is AspNetUsers.

My Code

  public class ApplicationUser : IdentityUser
  {
    public string FirstName { get; set; }  
  }

Solution

  • ASP.NET Identity comes with some default tables like Users, Roles, Logins, etc. Those tables are defined by the classes IdentityUser, IdentityRole, IdentiyLogin, etc.

    Your ApplicationUser derives from the IdentityUser, that's why EF knows that's the [dbo].[AspUser] table. All those identity classes can be extended, like you did. Just inherit them and add other properties.

    Here is the official website. There is a well documented intro video abot he ASP.NET Identity. Take a look.