internal void CreateTablesIfNeeded() { using (var db = ConnectToDatabase()) { if (!SimpleMembershipProvider.CheckTableExists(db, RoleTableName)) { db.Execute(@"CREATE TABLE " + RoleTableName + @" ( RoleId int NOT NULL PRIMARY KEY IDENTITY, RoleName nvarchar(256) NOT NULL UNIQUE)"); db.Execute(@"CREATE TABLE " + UsersInRoleTableName + @" ( UserId int NOT NULL, RoleId int NOT NULL, PRIMARY KEY (UserId, RoleId), CONSTRAINT fk_UserId FOREIGN KEY (UserId) REFERENCES " + SafeUserTableName + "(" + SafeUserIdColumn + @"), CONSTRAINT fk_RoleId FOREIGN KEY (RoleId) REFERENCES " + RoleTableName + "(RoleId) )"); } } }