开发者

Update User Entity Framework

I am writing an asp.net membership provider using Entity code first and I need some help understanding how to Update the MembershipUser object.

The UpdateUsert(MembershipUser user) override method needs to be implemented and consists of a MembershipUser parameter.

The following code does not work and I am not sure how to t开发者_如何学Cie the MembershipDBContext with the supplied membership user so that the user is updated. Thanks for the help.

public override void UpdateUser(MembershipUser user)
{
    MembershipDBModel userToUpdate = _getMembershipDBModelUser(user.UserName);

    userToUpdate.IsLockedOut = user.IsLockedOut;


    using (MembershipDBContext db = new MembershipDBContext())
    {
        db.SaveChanges();
    }
}


Why not use the built in functionality for the MembershipProvider?

MembershipUser user = Membership.GetUser();
user.IsApproved = false;
Membership.UpdateUser(user);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜