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:
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 = "[email protected]"
});
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?
I asked the same question to the product team.
The design goal of SIMPLE membership was to work out-of-the box as simple as possible.
So really there's no customization possible as far as the tables are concerned. The recommended workaround is, to still use ASP.NET Membership (SqlMembershipProvider).