1

是否可以添加字段/列webpages_Membership

[Table("webpages_Membership")]
public class Membership
{
public Membership()
{
    Roles = new List<Role>();
    OAuthMemberships = new List<OAuthMembership>();
}

[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public int UserId { get; set; }
public DateTime? CreateDate { get; set; }
[StringLength(128)]
public string ConfirmationToken { get; set; }
public bool? IsConfirmed { get; set; }
public DateTime? LastPasswordFailureDate { get; set; }
public int PasswordFailuresSinceLastSuccess { get; set; }
[Required, StringLength(128)]
public string Password { get; set; }
public DateTime? PasswordChangedDate { get; set; }
[Required, StringLength(128)]
public string PasswordSalt { get; set; }
[StringLength(128)]
public string PasswordVerificationToken { get; set; }
public DateTime? PasswordVerificationTokenExpirationDate { get; set; }

public ICollection<Role> Roles { get; set; }

[ForeignKey("UserId")]
public ICollection<OAuthMembership> OAuthMemberships { get; set; }
}

我想将 LogonCount 添加为字段/列,但是membership provider在创建CreateUserAndAccount().

我似乎对给 LogonCount 的值没有任何影响CreateUserAndAccount()

4

1 回答 1

1

添加与给定 userId 相关的信息的标准方法是在UserProfile表中,而不是在webpages_Membership表中。有关SimpleMembership如何与. _ _ _UserProfile

我似乎对给 LogonCount 一个值没有任何影响......

然后,您可以通过您的数据库上下文访问UserProfile表和信息,而不是通过成员资格提供程序,它实际上只允许您访问一组核心功能。

using (MyDbContext db = new MyDbContext())
{
  UserProfile user = db.UserProfiles
    .First(u => u.UserName.ToLower() == model.UserName.ToLower());
  user.LogonCount = 1;
  db.SaveChanges();
}
于 2013-05-18T18:54:16.040 回答