Below you will find the t-sql code needed to generate de SQL Server SimpleMembershipProvider tables.

 

 

set ansi_nulls on
go
set quoted_identifier on
go

if object_id('dbo.webpages_Membership') is null
begin
    create table dbo.webpages_Membership
    (
        UserId                                    int not null constraint PK_Membership_UserId primary key,
        CreateDate                                datetime null,
        ConfirmationToken                        nvarchar(128) null,
        IsConfirmed                                bit null constraint DF_Membership_IsConfirmed default (0),
        LastPasswordFailureDate                    datetime null,
        PasswordFailuresSinceLastSuccess        int not null constraint DF_Membership_PasswordFailuresSinceLastSuccess default (0),
        [Password]                                nvarchar(128) not null,
        PasswordChangedDate                        datetime null,
        PasswordSalt                            nvarchar(128) not null,
        PasswordVerificationToken                nvarchar(128) null,
        PasswordVerificationTokenExpirationDate    datetime null
    )
end
go
set ansi_nulls on
go
set quoted_identifier on
go

if object_id('dbo.webpages_Roles') is null
begin
    create table dbo.webpages_Roles
    (
        RoleId int identity(1,1) not null,
        RoleName nvarchar(256) not null,
        constraint PK_Roles_RoleId primary key clustered 
        (
            RoleId ASC
        ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [PRIMARY],
        constraint UQ_Roles_RoleName unique nonclustered 
        (
            RoleName asc
        ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [PRIMARY]
    )
end
go
set ansi_nulls on
go
set quoted_identifier on
go

if object_id('dbo.webpages_OAuthMembership') is null
begin
    create table dbo.webpages_OAuthMembership
    (
        Provider        nvarchar(30) not null,
        ProviderUserId    nvarchar(100) not null,
        UserId            int not null,
        constraint PK_OAuthMembership_Provider_ProviderUserId primary key clustered 
        (
            Provider asc,
            ProviderUserId asc
        ) with    (    pad_index = off, 
                    statistics_norecompute = off,
                    ignore_dup_key = off,
                    allow_row_locks = on,
                    allow_page_locks = on) on [PRIMARY]
    )
end
go
set ansi_nulls on
go
set quoted_identifier on
go

if object_id('dbo.webpages_UserProfile') is null
begin
    create table dbo.webpages_UserProfile
    (
        UserId int identity(1,1) not null,
        UserName nvarchar(56) not null,
        constraint PK_UserProfile_UserId primary key clustered 
        (
            UserId asc
        ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [PRIMARY],
        constraint UQ_UserProfile_UserName unique nonclustered 
        (
            UserName asc
        ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [PRIMARY]
    )
end
go
set ansi_nulls on
go
set quoted_identifier on
go

if object_id('dbo.webpages_UsersInRoles') is null
begin
    create table dbo.webpages_UsersInRoles
    (
        UserId int not null constraint FK_UsersInRoles_UserId foreign key(UserId) references dbo.webpages_UserProfile (UserId),
        RoleId int not null constraint FK_UsersInRoles_RoleId foreign key(RoleId) references dbo.webpages_Roles (RoleId),
        primary key clustered 
        (
            UserId asc,
            RoleId asc
        ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on PRIMARY]
    )
end
go

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.