I'm working for the first time with Membership Reboot and I have custom class. I added a new property called Middle Name. How can I do the EF Migration on this to get it updated?
public class CustomUser : RelationalUserAccount
{
[Display(Name = "First Name")]
public virtual string FirstName { get; set; }
[Display(Name = "Last Name")]
public virtual string LastName { get; set; }
[Display(Name = "Middle Name")]
public virtual string MiddleName { get; set; }
public virtual int? Age { get; set; }
}
public class CustomUserAccountService : UserAccountService<CustomUser>
{
public CustomUserAccountService(CustomConfig config, CustomUserRepository repo)
: base(config, repo)
{
}
}
public class CustomUserRepository : DbContextUserAccountRepository<CustomDatabase, CustomUser>
{
public CustomUserRepository(CustomDatabase ctx)
: base(ctx)
{
}
}
Enable-Migrations
command for your projectAdd an initial migration before changing any properties to set the initial state in your project
add-migration -Name Initial
Create the initial table structure in the database.
Update-Database
Add the MiddleName property in the customUser class
Add new migration for the changes you have done.
add-migration -Name middleName_added
Update the database to reflect the new changes in database
Update-Database