asp.net-mvc – 如何手动创建简单的成员资格sql表?

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 如何手动创建简单的成员资格sql表?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在寻找一个类似于Aspnet_regsql.exe for ASP .NET Membership的工具,仅适用于simpleMemberShip Provider.在运行时创建表太晚了,导致客户端程序使用相同的表.
UserProfile
webpages_Membership
webpages_OAuthMembership
webpages_Roles
webpages_UsersInRoles

任何建议都会很棒

解决方法

在开发人员计算机上运行应用程序后,您可以使用sql Management Studio自行创建脚本:

示例来自我所做的类似任务(注意日期,不确定是否有任何更改).

注意:您需要像创建任何生产系统一样创建数据库并执行常规权限设置等.

/****** Object:  Table [dbo].[UserProfile]    Script Date: 12/06/2012 18:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[UserProfile](
    [UserId] [int] IDENTITY(1,1) NOT NULL,[UserName] [nvarchar](56) NOT NULL,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],UNIQUE NONCLUSTERED 
(
    [UserName] ASC
)WITH (PAD_INDEX  = OFF,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


/****** Object:  Table [dbo].[webpages_Membership]    Script Date: 12/06/2012 18:18:52 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[webpages_Membership](
    [UserId] [int] NOT NULL,[CreateDate] [datetime] NULL,[ConfirmationToken] [nvarchar](128) NULL,[IsConfirmed] [bit] NULL,[LastPasswordFailureDate] [datetime] NULL,[PasswordFailuresSinceLastSuccess] [int] NOT NULL,[Password] [nvarchar](128) NOT NULL,[PasswordChangedDate] [datetime] NULL,[PasswordSalt] [nvarchar](128) NOT NULL,[PasswordVerificationToken] [nvarchar](128) NULL,[PasswordVerificationTokenExpirationDate] [datetime] NULL,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[webpages_Membership] ADD  DEFAULT ((0)) FOR [IsConfirmed]
GO

ALTER TABLE [dbo].[webpages_Membership] ADD  DEFAULT ((0)) FOR [PasswordFailuresSinceLastSuccess]
GO

/****** Object:  Table [dbo].[webpages_OAuthMembership]    Script Date: 12/06/2012 18:19:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[webpages_OAuthMembership](
    [Provider] [nvarchar](30) NOT NULL,[ProviderUserId] [nvarchar](100) NOT NULL,[UserId] [int] NOT NULL,PRIMARY KEY CLUSTERED 
(
    [Provider] ASC,[ProviderUserId] ASC
)WITH (PAD_INDEX  = OFF,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

/****** Object:  Table [dbo].[webpages_Roles]    Script Date: 12/06/2012 18:19:26 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[webpages_Roles](
    [RoleId] [int] IDENTITY(1,[RoleName] [nvarchar](256) NOT NULL,PRIMARY KEY CLUSTERED 
(
    [RoleId] ASC
)WITH (PAD_INDEX  = OFF,UNIQUE NONCLUSTERED 
(
    [RoleName] ASC
)WITH (PAD_INDEX  = OFF,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

/****** Object:  Table [dbo].[webpages_UsersInRoles]    Script Date: 12/06/2012 18:19:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[webpages_UsersInRoles](
    [UserId] [int] NOT NULL,[RoleId] [int] NOT NULL,PRIMARY KEY CLUSTERED 
(
    [UserId] ASC,[RoleId] ASC
)WITH (PAD_INDEX  = OFF,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[webpages_UsersInRoles]  WITH CHECK ADD  CONSTRAINT [fk_RoleId] FOREIGN KEY([RoleId])
REFERENCES [dbo].[webpages_Roles] ([RoleId])
GO

ALTER TABLE [dbo].[webpages_UsersInRoles] CHECK CONSTRAINT [fk_RoleId]
GO

ALTER TABLE [dbo].[webpages_UsersInRoles]  WITH CHECK ADD  CONSTRAINT [fk_UserId] FOREIGN KEY([UserId])
REFERENCES [dbo].[UserProfile] ([UserId])
GO

ALTER TABLE [dbo].[webpages_UsersInRoles] CHECK CONSTRAINT [fk_UserId]
GO
原文链接:https://www.f2er.com/aspnet/247599.html

猜你在找的asp.Net相关文章