1

Is it ok to delete records from ASP.NET identity tables AspNetUSers, AspNetRoles and AspNetUserRoles directly from SQL Server using T-SQL? The ASP.NET Core app is using only these three identity tables other AspNet... tables are empty.

UPDATE:

Why we want to do it directly through T-SQL since app has several users (with one role) and client wants to get rid of all the users quickly in one shot.

nam
  • 21,967
  • 37
  • 158
  • 332
  • Sure you can, but I wonder, why would you want to do this? Why don't you use the storage provider to take care of this? –  Aug 13 '17 at 08:35
  • @RuardvanElburg Good question. I've added an **UPDATE** section to answer it for other readers' benefit as well. – nam Aug 13 '17 at 15:51

1 Answers1

0

It is ok to delete rows from AspNetUsers, AspNetRoles or AspNetUserRoles. Because IdentityServer does the same. For example check the SQL statements which are generated when deleting a user through the UserStore class.

user743414
  • 936
  • 10
  • 23
  • Do you have sources that support this statement or is it just your opinion? –  Aug 14 '17 at 16:23
  • The source are the generated SQL statements which are executed when you create/delete users through the UserStore. – user743414 Aug 15 '17 at 06:30
  • Sorry, that is not what I meant. Are there credible and/or official sources that you can link in your answer? Why is it ok to delete rows? –  Aug 15 '17 at 07:58
  • At least you could have added a link. But I do not see how this answers the question. You are missing the part 'directly from SQL Server using T-SQL'. –  Aug 15 '17 at 10:31
  • There's no link where you can see a SQL statement. therefore I do not understand what you're looking for. Take a look at the UserStore class and check the generated and executed SQL statements. I can't see a reason why it shouldn't be ok to do the same. – user743414 Aug 15 '17 at 10:51