Storing Custom Fields During User Registration In A Separate Table – C# ASP.NET Identity

There are tons of great tutorials on how to add custom fields during the registration process in ASP.NET MVC5 using User Identity.  I found the following articles to be quite useful.


However, those articles will add the custom fields right into the AspNetUser tables which isn’t what I want.  I like to keep that table as close to standard as possible and store custom site data in it’s own table.  In order to do this, I hope sharing the following code will be useful to someone.

// IdentityModel.cs
public class ApplicationUser : IdentityUser
   public virtual UserProfileInfo UserProfileInfo { get; set; }

public class UserProfileInfo
   [Key, ForeignKey("ApplicationUser")]
   public string Id { get; set; }
   public virtual ApplicationUser ApplicationUser { get; set; }

   public string FirstName { get; set; }
   public string LastName { get; set; }

public class ApplicationDbContext : 
   public DbSet<UserProfileInfo> UserProfileInfo { get; set; } 

As you can see from the code above, a new table called UserProfileInfo will be created with 

  • id (primary key, and foreign key to the AspNetUser table)
  • firstname
  • lastname

And that’s basically it.  Enjoy!