删除失效/丢失的应用程序来自 ASP.NET SQL memership DB 的引用?

发布于 2024-11-06 18:46:08 字数 467 浏览 2 评论 0 原文

创建我的第一个网站,该网站使用 ASP.NET (v4) 中提供的登录/会员系统。

到目前为止,一切都很好,使用 web.config 将其指向远程 SQL 服务器,并且它正在工作。

我最初没有为成员资格提供程序指定“applicationName”,因此当查看 SQL Server 中的表时,它会将名称显示为“/”。

我更新了 web.config 并添加了分配名称所需的 Membership 和 Provider 部分,分配了一个名称,然后运行 ​​ASP.NET 配置向导来重新初始化用户数据库。

在 SQL Server 中,应用程序现在显示其名称和新的 GUID,并按预期工作。

我的问题是,是否有一种自动方法可以从各种 ASP.NET SQL 表中删除与“旧站点”关联的所有(现在不需要的)记录,还是我必须手动执行此操作?

如果我需要手动执行此操作,是否有人知道一组已制定的程序以确保从数据库中删除所有引用?

Creating my first site that uses the login/membership system provided in ASP.NET (v4).

So far all is good, used the web.config to point it at a remote SQL server, and it's working.

What I didn't do originally was specify an 'applicationName' for the membership provider, so when looking at the table(s) in the SQL server it shows the name as "/".

I updated the web.config and added the Membership and Provider sections needed to assign a name, assigned one, and ran the ASP.NET Configuration Wizard to re-initialize the user DB.

In the SQL server the application now shows its name and a new GUID, and works as expected.

My question is, is there an automated way to get rid of all the (now unneeded) records associated to the 'old site' from the various ASP.NET SQL table(s), or am I stuck doing it manually?

If I need to do this manually, is anyone aware of a laid out set of procedures to ensure all references are removed from the DB?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风夜微凉 2024-11-13 18:46:08

我过去在我的开发机器上使用过这个脚本,没有出现任何问题。我不能说我真的和会员提供商一起去过城里,所以我只在用户和角色表中拥有数据,但我认为这个脚本应该整理所有内容。

当然,在运行之前请先进行备份,因为我还没有在它周围添加任何事务。

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

I have used this script on my development machine with no issues in the past. I can't say that I have ever really gone to town with the membership provider so I have only ever had data in the users and roles table but I think this script should tidy everything up.

Make a backup before you run it of course as I haven't added any transactions around it.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文