Yes you can. However I do not think WebSecurity
provides a way to update extra column in membership tables e.g. UserProfile through its API.
This is how we did it, we have MVC4 ASP.NET internet application project and we are using EF5.0 Code First.
You already know how to add extra column in the UserProfile table (table name can be anything).
Once we have a class (that has all required extra columns along with UserId and UserName),
- Added a controller
UserController
dedicated to facilitate CRUD operation for UserProfile. - UserController uses a
UserService
class in business layer that is taking care of all CRUD operation on UserProfile class (entity). On Edit Post operation, controller call UserService class
UpdateUser()
method which looks like below:public void UpdateUser(UserProfile user) { Guard.ArgumentNotNull(user, "user"); if (_roleWrapper.GetRolesForUser(user.UserName).Any()) { _roleWrapper.RemoveUserFromRoles(user.UserName, _roleWrapper.GetRolesForUser(user.UserName)); } if (!_roleWrapper.IsUserInRole(user.UserName, user.Role)) { _roleWrapper.AddUserToRole(user.UserName, user.Role); } _dataContext.Update<UserProfile>(user); }
Above text and sample is for example only, you can simplify it. Basically you need to get hold of UserProfile class and using DbContext to update it manually. WebSecurity
has limited APIs keeping simplicity in mind.
Hope that helps (if anything confusing please let me know, i will expand further).