Im trying to update an User and get nullreference. This is my code for updating user, i get the nullreference when i set the firstname in the else (when the object dont exist, then i tried to create it but it dont work)
the properties work fine, because my registration works and if the userprofile object exist on the user it's also fine
  var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
        var currentUser = manager.FindById(User.Identity.GetUserId());
        if (currentUser.UserProfileInfo != null)
        {
            currentUser.UserProfileInfo.FirstName = Firstname.Text;
            currentUser.UserProfileInfo.LastName = Lastname.Text;
            currentUser.UserProfileInfo.Adress = Adress.Text;
            currentUser.UserProfileInfo.Zip = Zip.Text;
            currentUser.UserProfileInfo.City = City.Text;
            currentUser.UserProfileInfo.Mobile = Mobile.Text;
            manager.UpdateAsync(currentUser);
        }
        else
        {
            UserProfileInfo UserProfileInfo = new UserProfileInfo();
            currentUser.UserProfileInfo.FirstName = Firstname.Text;
            currentUser.UserProfileInfo.LastName = Lastname.Text;
            currentUser.UserProfileInfo.Adress = Adress.Text;
            currentUser.UserProfileInfo.Zip = Zip.Text;
            currentUser.UserProfileInfo.City = City.Text;
            currentUser.UserProfileInfo.Mobile = Mobile.Text;
            manager.UpdateAsync(currentUser);
        }
Thanks
 
    