Last active
December 18, 2023 12:32
-
-
Save khurramkhang/f9110994e6dd771db87e0e26a394c557 to your computer and use it in GitHub Desktop.
Migrate Users to ASP.Net Identity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from [dbo].[Users] | |
INSERT INTO AspNetUsers(Id, | |
UserName, | |
Email, | |
PasswordHash, | |
SecurityStamp, | |
EmailConfirmed, | |
PhoneNumber, | |
PhoneNumberConfirmed, | |
TwoFactorEnabled, | |
LockoutEndDateUtc, | |
LockoutEnabled, | |
AccessFailedCount, | |
IsApproved, | |
IsLockedOut, | |
LastLoginDate, | |
LastLockoutDate, | |
Comment, | |
CreationDate) | |
SELECT | |
[dbo].[Users].UserId, | |
[dbo].[Users].UserName, | |
[dbo].[Memberships].Email, | |
([dbo].[Memberships].Password+'|'+CAST([dbo].[Memberships].PasswordFormat as varchar)+'|'+[dbo].[Memberships].PasswordSalt), | |
NewID(), | |
'true', | |
NULL, | |
'false', | |
'false', | |
[dbo].[Memberships].LastLockoutDate, | |
'true', | |
'0', | |
[dbo].[Memberships].IsApproved, | |
[dbo].[Memberships].IsLockedOut, | |
[dbo].[Memberships].LastLoginDate, | |
[dbo].[Memberships].LastLockoutDate, | |
[dbo].[Memberships].Comment, | |
[dbo].[Memberships].CreateDate | |
FROM [dbo].[Users] | |
INNER JOIN [dbo].[Memberships] ON [dbo].[Memberships].ApplicationId = [dbo].[Users].ApplicationId | |
AND [dbo].[Users].UserId = [dbo].[Memberships].UserId; | |
insert into [dbo].AspNetRoles (Id,Name) select RoleId, RoleName from [dbo].Roles | |
insert into [dbo].AspNetUserRoles(RoleId, UserId) select RoleId, UserId from [dbo].UsersInRoles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment