问题
I am trying to add a piece of data to the Asp identity table which stores user details (AspNetUsers
). I have code to create a new user but not how to add or change things in a table. Could someone link me a resource or show me an example of how to do this?
For example if I created users where age was null and had a form that asked a user to input an age and wanted to add that to the users information without having to create a new user.
I have all the code to collect the variable.
I have added migrations for the new columns and created the columns in the table, I just need to add the data for the user that is currently logged in.
回答1:
Have you tried this
var user = await UserManager.FindByNameAsync(User.Identity.Name);
user.Age = 25;
IdentityResult result = await UserManager.UpdateAsync(user);
来源:https://stackoverflow.com/questions/43307810/save-new-data-to-user-table-using-asp-identity