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);
精彩评论