tec*_*007 6 sql-server asp.net asp.net-membership
创建我的第一个使用ASP.NET(v4)中提供的登录/成员资格系统的站点.
到目前为止一切都很好,使用web.config将它指向远程SQL服务器,它正在工作.
我最初没有做的是为成员资格提供程序指定'applicationName',因此当查看SQL服务器中的表时,它将名称显示为"/".
我更新了web.config并添加了分配名称,分配名称和运行ASP.NET配置向导以重新初始化用户数据库所需的成员资格和提供程序部分.
在SQL Server中,应用程序现在显示其名称和新GUID,并按预期工作.
我的问题是,是否有一种自动方法可以从各种ASP.NET SQL表中删除与"旧站点"关联的所有(现在不需要的)记录,或者我是不是手动操作它?
如果我需要手动执行此操作,是否有人知道一组布置的过程以确保从数据库中删除所有引用?
flu*_*ent 11
我在我的开发机器上使用过这个脚本,过去没有任何问题.我不能说我真的和会员提供商一起去了城镇,所以我只有用户和角色表中的数据,但我认为这个脚本应该整理一切.
在运行之前进行备份,当然我没有在它周围添加任何交易.
DECLARE @APPID UNIQUEIDENTIFIER
--Change the application id to the app you want to clear out
SET @APPID = 'bb5f1064-062d-4a21-875c-dc15c1e9ec27'
delete from aspnet_Membership Where UserId in ( Select UserId From aspnet_Users Where ApplicationId = @APPID)
delete from aspnet_PersonalizationPerUser Where PathId in ( Select PathId From aspnet_Paths Where ApplicationId = @APPID)
delete from aspnet_PersonalizationAllUsers Where PathId in ( Select PathId From aspnet_Paths Where ApplicationId = @APPID)
delete from aspnet_Paths Where ApplicationId = @APPID
delete from aspnet_PersonalizationPerUser Where UserId in ( Select UserId From aspnet_Users Where ApplicationId = @APPID)
delete from aspnet_Profile Where UserId in ( Select UserId From aspnet_Users Where ApplicationId = @APPID)
delete from aspnet_UsersInRoles Where RoleId in( Select RoleId from aspnet_Roles Where ApplicationId = @APPID)
delete from aspnet_Roles Where ApplicationId = @APPID
delete from aspnet_Users Where ApplicationId = @APPID
delete from aspnet_Applications Where ApplicationId = @APPID
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
664 次 |
| 最近记录: |