How can I save to a secondary Identity table in ASP.NET MVC?

So I have the following code here which allows the use of a second table to store user profile values:

public class ProfileUser : IdentityUser
{
    public virtual ProfileUserInfo ProfileUserInfo { get; set; }
}
public class ProfileUserInfo
{
    public int Id { get; set; }
    public DateTime JoinDate { get; set; }
    public String Title { get; set; }
    public String Avatar { get; set; }
    public String TimeZone { get; set; }
}
public class ProfileDbContext : IdentityDbContext<ProfileUser>
{
    public ProfileDbContext()
        : base("DefaultConnection")
    {
    }
    public System.Data.Entity.DbSet<ProfileUserInfo> ProfileUserInfo { get; set; }
}

Being someone who has not the slightest idea on how to work with entity framework, how can I save a new ProfileUser to the database? The goal is for both a ProfileUser and Normal ASP.NET Identity user to be created upon account creation in the Account Controller.

Thanks!

I feel.

context.saveChanges() should save all the changes done to the entities.

 

Leave a Reply