# Bulk migration of users from custom database

**URL:** <https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368>\
**Category:** Get Help\
**Tags:** database-migration, user-migration, custom-database\
**Created:** [January 22, 2019, 10:16pm UTC](https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368 "2019-01-22T22:16:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djm-ite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/djm-ite/32/10289_2.png) [@djm-ite](https://community.auth0.com/u/djm-ite)\
**Post date:** [January 22, 2019, 10:16pm UTC](https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368/1 "2019-01-22T22:16:31Z")

</div>

As a bit of context, we are migrating from our existing OWIN-based authentication using an MSSQL database to Auth0. Having looked at material on migrating from a custom database ([here](http://community.auth0.com/t/custom-database-with-automatic-migration-resetting-password-for-un-migrated-users/17481/7) and [here](http://community.auth0.com/t/legacy-database-user-migration/8535/2)), I understand that the default is for the Auth0 record to be set up on-the-fly when each user first signs in via Auth0 since the deployment.

Our intention is to set up ‘stub’ user records in Auth0 via the Management API and still use the custom DB connection for that first password verification if possible, since:

- We have an existing user ID that is referenced by other records in other parts of our system, hence we want to maintain referential integrity with the user\_id (which we can set when creating the user via the Management API)
- We want to efficiently populate referential data from our Azure CosmosDB into the app\_metadata field on a many-to-many basis, so that custom rules can append the relevant claims to the User identity returned to the web application.
- If the source data in CosmosDB changes, our system now updates corresponding user records in Auth0 instead of the SQL database; we cannot rely on old claims in the UserClaim SQL table since that is no longer being used by the application. Therefore we need the relevant User records in Auth0 from the start.

We still expect the users to have a seamless experience signing in with their existing password. Is it possible for us to maintain this sign-in experience via the custom DB, if our user records are bulk-migrated to Auth0? If so, how do we ensure that the custom DB is still consulted for that first post-deployment sign-in per user (i.e. how do we mark the corresponding Auth0 record as ‘dormant’)?

If these needs are mutually exclusive and we cannot create user records in Auth0 as part of our deployment, how do we ensure that the Auth0 record contains the data (user\_id, app\_metadata and user\_metadata) that we need? Can we explicitly set the user\_id to maintain referential integrity as we could when creating the user via the Management API?

Many thanks.

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [January 25, 2019, 3:24am UTC](https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368/4 "2019-01-25T03:24:13Z")

</div>

Hey there @djm-ite, I wanted to reach out and let you know I am looking for insight on this scenario from our team. I will reach back out as soon as I have more feedback. Thanks!

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [February 8, 2019, 10:39pm UTC](https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368/5 "2019-02-08T22:39:11Z")

</div>

@djm-ite after confirming with support, we actually have this [configure automatic migration from your database](https://auth0.com/docs/users/guides/configure-automatic-migration) document that should really streamline the process for you. Please let me know if this aids you in your quest. Thanks!

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [February 23, 2019, 2:47am UTC](https://community.auth0.com/t/bulk-migration-of-users-from-custom-database/20368/6 "2019-02-23T02:47:18Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
