Add Fields to User Table
Now I would like to add 3 fields to the AspNetUser that will be created for us. In addition to the login information, I would like to add a First Name field, Last Name field, and an Employee Number field to the table.
For simplicity sake, I would just want all the new fields to be nvarchar(128) fields in the database and have the First Name and Last Name be “NOT NULL”
Lets get the file we need to update.
Grab the IdentityModels.cs file and look for the ApplcationUser class.
Now add the 3 new fields as properties to the ApplicationUser class.
Notice the Data Annotations. In order to use those we need to add the Data Annotations using statement:
The [Required] annotation will make sure our database field is NOT NULL. Also, the [MaxLength] annotation, along with the string type, will create our field as an nvarchar with a length of 128 characters.
Next I want to create a new table that will house our Applications information.