开发者

Update User Entity Framework

开发者 https://www.devze.com 2023-03-05 13:07 出处:网络
I am writing an asp.net membership provider using Entity code first and I need some help understanding how to Update the MembershipUser object.

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

精彩评论

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