0

我有 table UserProfile,其中有一些额外的字段,如 email、typeAccount、isActivated 等。
当我得到 时Membership.GetUser().(..),我没有这些字段。
如何解决?以及如何更改此字段的值?

[Table("UserProfile")]
public class UserProfile
{

    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int UserId { get; set; }
    public string UserName { get; set; }
    public string Email { get; set; }
    public int typeAccount { get; set; }
    public bool activated { get; set; }
    public string activationcode { get; set; }
    public bool del { get; set; }
}

问候

4

1 回答 1

3

会员提供者不处理个人资料。如果要检索当前经过身份验证的用户的 UserProfile 记录,只需使用上下文:

[Authorize]
public ActionResult SomeAction()
{
    using (UsersContext db = new UsersContext())
    {
        UserProfile user = db
            .UserProfiles
            .FirstOrDefault(u => u.UserName == User.Identity.Name);

        // do something with the profile
    }

    ...
}
于 2013-03-11T12:33:04.103 回答