0

I am trying to use SimpleMembership with my own database that already has all the users/roles/etc...

To that end, I change the WebSecurity.InitializeDatabaseConnection line in the SimpleMembershipInitializer constructor to point to my own table (note autoCreateTables: true):

WebSecurity.InitializeDatabaseConnection("NameOfMyConnectionString", "User", 
                               "UserId", "DomainLogin", autoCreateTables: true);

I then created my own provider where I overrode the 'ValidateUser' method.

At this point, I fired up the app, logged in and then logged out (that is all that's required for my app - account creation is elsewhere). I looked at my database and the following tables were created: webpages_Membership, webpages_OAuthMembership, webpages_Roles, webpages_UsersInRoles. However, there was nothing in the tables. I fired up the Profiler, repeated the operation and in no way were those tables ever being referenced.

So am I safe changing the autoCreateTables parameter from true to false?

P.S. Yes, I read this question, but it did not answer my specific question.

Community
  • 1
  • 1
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • If your membership tables exist in the database you probably want `autoCreateTables: false` just so you don't accidentally blow away existing records or create new unwanted tables. – Jasen Mar 21 '14 at 21:33

1 Answers1

1

Basically, the MVC team wanted to give folks the ability to get up and running quickly without having to do a lot of the mundane user\role provisioning that comes with a brand new project - the concept being, get a database, create some kind of users table, and let the SimpleMembershipProvider take care of the rest (it's just so simple!).

Since you've already started down the path of creating your own custom provider, there is no reason to have those extra tables, so you're absolutely safe to set autoCreateTables to false.

X3074861X
  • 3,709
  • 5
  • 32
  • 45