I want to enable the ASP.NET MVC 4's SimpleMembership API to integrate with my own database schema. I have a plain and simple table in my database called Users
with these fields:
- Id
- Name
- Password
- Email
- IsDeleted
I have already configured the SimpleMembership API to use my database:
WebSecurity.InitializeDatabaseConnection("MyStuff", "Users", "Id", "Name", autoCreateTables: true);
And I can insert a user too:
WebSecurity.CreateUserAndAccount(model.UserName, model.Password,
new
{
IsDeleted = false,
Email = "sampledata@gmail.com"
});
However, the Password field (or it's hash) is not inserted into the Users table (of course), it inserted into another table called webpages_Membership
which is created with the InitializeDatabaseConnection
call and contains a lot of unnecessary information which I don't need.
Also, I have other automatically created tables called webpages_OAuthMembership, webpages_Roles and webpages_UsersInRoles which I don't need.
I've already tried to set the table generation to false:
WebSecurity.InitializeDatabaseConnection("MyStuff", "Users", "Id", "Name", autoCreateTables: false);
But in this case the CreateUserAndAccount call will throw an exception because it will not find the webpages_Membership table.
It looks like these tables needed when I want to use the SimpleMembership API.
My question is that: what should I do in a scenario like this when I want only a simple Users
table and nothing more?
Do I have to write the whole membership handling and the authentication logic (hash code generation, etc.) myself?
See Question&Answers more detail:
os