如何从备份数据库恢复选定的 ASP.NET 会员用户?

发布于 2024-10-16 19:43:14 字数 162 浏览 2 评论 0原文

我的 CMS 最近出现了问题,今天发现我上周创建的所有用户都被删除了。好消息是我有数据库的备份,并且它使用标准 ASP.NET 成员资格表。

有没有办法在不恢复整个数据库的情况下恢复这些数据?成员资格表有点像迷宫......是否有现有的存储过程或实用程序?我不确定哪些表是必需的,哪些表不需要。

Had a recent issue with my CMS and discovered today that all of my users created in the last week were deleted. The good news is that I have a backup of the DB, and that it uses standard ASP.NET Membership tables.

Is there a way to do a restore of this data without restoring the whole DB? The membership tables are something of a maze... is there an existing stored proc or utility out there? I'm not sure which tables would be required and which ones would not.

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

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

发布评论

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

评论(2

昇り龍 2024-10-23 19:43:14

我不知道有任何单个存储过程或实用程序可以执行此操作。

如果您仅使用会员资格,则需要从以下位置复制:

  • aspnet_Membership
  • aspnet_Users

如果您还使用角色,则需要从以下位置复制:

  • aspnet_UsersInRoles

如果您还使用配置文件,则需要从以下位置复制:

  • aspnet_Profile

所以基本上还不错。您只需要卷起袖子,编写 2 到 4 条插入语句即可。 (至少这是理论)

I'm not aware of any single sproc or utility to do this.

If you're using just the Membership, you'll need to copy from:

  • aspnet_Membership
  • aspnet_Users

If you're also using Roles you'll need to copy from:

  • aspnet_UsersInRoles

If you're also using Profile you'll need to copy from:

  • aspnet_Profile

So basically it's not that bad. You just need to roll up your sleeves and write between 2 and 4 insert statements. (that's the theory at least)

各自安好 2024-10-23 19:43:14

Greg 的正确答案的后续...这是我使用的实际 SQL 脚本:

INSERT INTO aspnet_Users
SELECT * FROM Restored.dbo.aspnet_Users WHERE UserId NOT IN (SELECT UserId FROM aspnet_Users)

INSERT INTO aspnet_Membership
SELECT * FROM Restored.dbo.aspnet_Membership WHERE UserID NOT IN (SELECT UserID FROM aspnet_Membership)

INSERT INTO aspnet_Profile
SELECT * FROM Restored.dbo.aspnet_Profile WHERE UserID NOT IN (SELECT UserID FROM aspnet_Profile)

INSERT INTO aspnet_UsersInRoles
SELECT * FROM Restored.dbo.aspnet_UsersInRoles WHERE UserID NOT IN (SELECT UserID FROM aspnet_UsersInRoles)

Follow-up to Greg's correct answer... here is the actual SQL script I used:

INSERT INTO aspnet_Users
SELECT * FROM Restored.dbo.aspnet_Users WHERE UserId NOT IN (SELECT UserId FROM aspnet_Users)

INSERT INTO aspnet_Membership
SELECT * FROM Restored.dbo.aspnet_Membership WHERE UserID NOT IN (SELECT UserID FROM aspnet_Membership)

INSERT INTO aspnet_Profile
SELECT * FROM Restored.dbo.aspnet_Profile WHERE UserID NOT IN (SELECT UserID FROM aspnet_Profile)

INSERT INTO aspnet_UsersInRoles
SELECT * FROM Restored.dbo.aspnet_UsersInRoles WHERE UserID NOT IN (SELECT UserID FROM aspnet_UsersInRoles)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文