Answer the question
In order to leave comments, you need to log in
ASP.NET MVC 5. Identity. How to get data from a separate table?
How to unload additional data about the user through the UserManager, which is stored in a separate table, which is connected on a one-to-one basis with the main table (AspNetUsers)
Now for more details:
in the class ApplicationUser : IdentityUser
, the property
public UserProfile UserProfile { get; set; }
and here is the model itself:
public class UserProfile
{
[Key,ForeignKey("ApplicationUser")]
public string ID { get; set; }
public ApplicationUser ApplicationUser { get; set; }
public DateTime? Birthday { get; set; }
}
newUser.UserProfile = new UserProfile {Birthday=birthday,ID = newUser.Id};
UserManager.Update(newUser);
ApplicationUser user = await UserManager.FindByNameAsync(userName)
сontext.Users.Include(Users => Users.UserProfile).Single(u => u.UserName==User.Identity.Name);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question