Search code examples
sql-serverpostgresqlasp.net-coreasp.net-core-identity

.Net Core Identity - migrate from Postgresql to SQL Server


I have a .NET Core 3.0 MVC website with Identity. The database is a Postgresql database (mainly because of better performance with geographic data). But since the only other person that can work with postgresql has quit, i have to migrate to SQL Server (because of internal policy).

But there isn't much information on the big web on this specific migration.

I got a few ideas but since setting up a test takes quite some time, I wanted to check here first.

  • Is it just a matter of copying all tables between the databases (Copy/export data - change connectionstring - people won't even notice the change)?
  • write a small script using entity framework, copying all users to the new database with a default password - users have to change password on first login
  • people have to re-register
  • a combination of the above

EDIT: the problem is not the tables and data types but my concern is the passwords and the hashes. Can I just copy all the values to the SQL database and can people just log in?

There is a password hash in the table and I was thinking it maybe used other variables like the database engine to create the hash.


Solution

  • If the application is build on the same stack, lets say in your case Dot net core with Aspnet Identity, then the hashes can be migrated with no issue at all. Everything is handled by dotnet and it is not bound to the underlying datastore.

    Create the schema and populate it and you will be good to go. No need to rehash or make your users change their passwords. Just move the data