更新时间:2023-02-16 16:26:08
我正在使用这个班级public class ApplicationUser:IdentityUser
{
public virtual UserInfo UserInfo {获得跨度>; set ; }
}
public class UserInfo
{
public int ID { get ; set ; }
public string FullName { get 跨度>; set ; }
}
public class ApplicationDbContext:IdentityDbContext< ApplicationUser>
{
public ApplicationDbContext()
: base ( AP)
{
}
public System.Data.Entity.DbSet< UserInfo> UserInfo { get ; set ; }
}
和var manager1 = new UserManager< applicationuser>( new UserStore< applicationuser>( new ApplicationDbContext()));
var currentUser = manager1.FindById(User.Identity.GetUserId());
currentUser.UserInfo.FullName = TextBox1.Text < / applicationuser > < / applicationuser > 跨度>
I am using this code to show user profile properties
var currentUserId = User.Identity.GetUserId();
var manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext()));
var currentUser = manager1.FindById(User.Identity.GetUserId());
TextBox1.Text = currentUser.UserInfo.FullName;
But how can update user profile properties below code is not working
var currentUserId = User.Identity.GetUserId();
var manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext()));
var currentUser = manager1.FindById(User.Identity.GetUserId());
currentUser.UserInfo.FullName = TextBox1.Text;
I am using this classpublic class ApplicationUser : IdentityUser { public virtual UserInfo UserInfo { get; set; } } public class UserInfo { public int Id { get; set; } public string FullName { get; set; } } public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("AP") { } public System.Data.Entity.DbSet<UserInfo> UserInfo { get; set; } }
andvar manager1 = new UserManager<applicationuser>(new UserStore<applicationuser>(new ApplicationDbContext())); var currentUser = manager1.FindById(User.Identity.GetUserId()); currentUser.UserInfo.FullName = TextBox1.Text</applicationuser></applicationuser>