2

In our ASP.NET MVC Core app we are using ASP.NET Idenity to implement user management.

Question: Instead of using ASP.NET user interface, how can we directly create a user into the SQL Database (using a SQL statement etc.)? Will creating a user directly in ASPNETUsers table cause any issue? Note: We need to populate built-in identity table ASPNETUsers from a list of users. Password can be anything and no specific role is required.

1
  • 1
    Have you tried? What happened when you tested this? Commented Jan 6, 2017 at 20:47

1 Answer 1

8

Here is the insert script for AspNetUsers

INSERT [dbo].[AspNetUsers] ([Id], [AccessFailedCount], [ConcurrencyStamp], 
[Email], [EmailConfirmed], [LockoutEnabled], [LockoutEnd], [NormalizedEmail], 
[NormalizedUserName], [PasswordHash], [PhoneNumber], [PhoneNumberConfirmed], 
[SecurityStamp], [TwoFactorEnabled], [UserName]) VALUES 
(N'0633e088-30a6-444f-9603-70d7c26748ef', 0, 
N'd2feada1-c7db-4f5a-801c-4ae5c990a49d', N'[email protected]', 1, 1, NULL, 
N'[email protected]', N'[email protected]', 
N'AQAAAAEAACcQAAAAEBqhdvkH3O3glua9IFU+LDamc3mj03dPQ/8brAW34GTN6kxMOqs5je90FNn7fuNleQ==', 
N'+10001234567', 1, N'6123adf0-fc53-4abb-b6a4-52d164da4e4f', 0, N'[email protected]')
GO

Of course you will need to generate your own Guids and hash your own password.

Sign up to request clarification or add additional context in comments.

1 Comment

How can I create password hash? Can I copy from my local to the server?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.