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
- 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?
You can use OAUth with ASP.NET Universal Providers. universal providers are the new version of sqlmembership providers. these are based on EF CodeFirst and also generate a more cleaner schema of your database look at my following post for more details http://blogs.msdn.com/b/pranav_rastogi/archive/2012/09/12/integrate-openauth-openid-with-your-existing-asp-net-application-using-universal-providers.aspx