In this article you will learn how to add Email and Details columns to an existing database. We get this database when running an application trying to create a new account. As you know, we don't see an email field in a user registration form as well as in the membership database. But we can enable this using some quick changes in the application. Read on.
In MVC we also have the opportunity to create a separate database table for users. In other words, we can add a new database table like "NewUsers" and we can hook this database table to membership from here (in the Filter > InitializeSimpleMembershipAttribute.cs file):
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "NewUsers", "Id", "Username", autoCreateTables: true);
Note: Remember to match "UserId" data in both tables "NewUsers" and "webpages_Membership", otherwise this will create a very big security hole in your application. Well that is not the subject of this article.
Now, let's go ahead and follow the steps to add Email and Details field to the database and update the Model, View and Controller to accept that data from the user.
Step 1: Update Database
Open the database and add the following fields.








Kai AbatPosted Jan 22, 2013, 9:44 PM
Im new in Asp.net mvc so can I ask if this approach can be use on MVC 3? if yes, where can I find this line of code you use in mvc 3?. WebSecurity.InitializeDatabaseConnection("DefaultConnection", "NewUsers", "Id", "Username", autoCreateTables: true);
Shelly GogiaPosted Nov 5, 2012, 10:17 PM
Nice info about adding the details in MVC.