I am an asp mvc 3 noob trying to modify the user account scaffolding to hold more information. When users create an account, I want to add additional information like their full name and start date–not just their username/pw. I am going to store this added info in an Employees table in the DB.
I see the line of code in the AccountController that creates the account after the user types in input to the form.
Membership.CreateUser(model.UserName, model.Password, model.Email, Nothing, Nothing, True, Nothing, createStatus)
It seems like this line calls a stored procedure in SQL server. It seems like the most likely stored procedure is aspnet_Membership_CreateUser. But this stored proc has 13 parameters, and the code above passes 8 parameters.
- What stored procedure is called by the VB code shown above (membership.createuser…)?
- Why don’t aspnet_Membership_CreateUser and Membership.CreateUser have the same number of parameters?
- How do I modify the create user code/stored procedure to add employee information into the EmployeeTable based on info from the registration form, and then add a link between the user account and the Employee record? In general, the idea would be to add the employee info as additional parameters to the stored proc and then have the stored proc do the inserts/add the ids, but where exactly do I look to do this?
The code will run the
aspnet_Membership_CreateUserstored procedureThe
Membership.CreateUseris overloaded, and will put default values for parameters that would not have been provided. For example, if you call CreateUser with just the username and password, all the other parameters will be defaulted, e.g. IsApproved will be true. >>When typing in CreateUser, you should see the overload options. You can look at the code in “C:\Windows\Microsoft.NET\Framework\v4.0.30319\system.web.dll” using a tool like Just DecompileThere are different ways of storing additional data. Look at this one. I prefer linking the tables by UserId/Email address, and when creating a user, I call the CreateUser, and if its successful, then save the additional data (which is a slight variation of the method described in that tutorial). You can also modify/extend the whole membership provider, see this link (Implementing a Membership Provider) or this video tutorial