InitializeDatabaseConnection (WebSecurity Ref)

Initializes a connection to the database specified and automatically creates the tables. It accepts five arguments.


WebSecurity.IntializeDatabaseConnection(string dbname, string usersTableName, stringuserIdColumn, string usernameColumn, bool autocreate tables)

The database should be stored in the App_Data folder, and this connection should be declared in the _AppStart file. The bool argument at the end will automatically create the tables if they do not exist.


WebSecurity.InitializeDatabaseConnection("MyDB", "UserProfile", "UserId", "Email", autoCreateTables: true);

In this example the username column is called “Email” because the usernames will be stored as emails.