MHOOS
MHOOS

Reputation: 5306

Removing ASP.NET Identity tables from a database

How can I remove ASP.NET Identity tables from a database? Right now I have the following tables added to my database :

I know that I could write something like the following :

DROP TABLE __MigrationHistory
DROP TABLE AspNetUserLogins
DROP TABLE AspNetUserRoles
DROP TABLE AspNetUserClaims
DROP TABLE AspNetRoles
DROP TABLE AspNetUsers

However I was wondering whether this is the right approach and if there is more elegant method of removing ASP.NET Identity tables and any other potential traces which I might have left out.

Upvotes: 4

Views: 3857

Answers (2)

Osman Taskiran
Osman Taskiran

Reputation: 359

You have to remove following tables from the database.

DROP TABLE __EFMigrationsHistory
Drop Table AspNetRoleClaims
DROP TABLE AspNetUserLogins
DROP TABLE AspNetUserRoles
DROP TABLE AspNetUserClaims
Drop Table AspNetUserTokens
DROP TABLE AspNetRoles
DROP TABLE AspNetUsers

Also you need to drop Identity schema, if it's already exists orphan in your database.

Upvotes: 4

trailmax
trailmax

Reputation: 35106

Just a note: __MigrationHistory is not part of Identity framework - it is table that stores information about DB state for EF-Migrations. If you would like to preserve the migration state and keep using the migrations, don't do anything to this table (unless you know what you are doing)

And I'll point out (seems like you have your answers already) that if you have created these tables by migration, you can roll back to "state-zero" by

update-database -target:0

This will run all your migrations back to the start and you'll be left with one table __MigrationHistory

Upvotes: 1

Related Questions