Is there a way to migrate existing database with all tables and relations to use SQL Server auto ids instead of Nhibernate (hilo) ids?
We have a .NET application which uses NHibernate. But the problem is, we are running out of int.
I know that this requires tables recreation with new ones which have ids set as auto incremented. Is there a easy way to migrate. For example some sort of query which will replicate tables, keep relations, but now with SQL Server ids instead of hilo ids. Biggest problem of hilo, it's using shared ids, which makes situation worse.
For example, we have a database of 3 tables:
dbo.Usersdbo.RegistrationResultsdbo.UserNotes
Tables:
dbo.Users
Idint (Primary)Emailnvarchar(255)RegistrationResultFkint (Foreign Key)
dbo.RegistrationResults
Idint (Primary)ValidationOutcomenvarchar(255)
dbo.UserNotes
Idint (Primary)Messagenvarchar(255)RegistrationResultFkint (Foreign Key)
And data populated like this:
dbo.Users
| Id | RegistrationResultFk | |
|---|---|---|
| 1 | test@gmail.com | 2 |
| 4 | test2@gmail.com | 5 |
dbo.RegistrationResults
| Id | ValidationOutcome |
|---|---|
| 2 | Awaiting confirmation |
| 5 | Confirmed |
dbo.UserNotes
| Id | Message | RegistrationResultFk |
|---|---|---|
| 3 | it's a test | 2 |
| 6 | it's a test 2 | 5 |
We want data after migration to look like:
dbo.Users
| Id | RegistrationResultFk | |
|---|---|---|
| 1 | test@gmail.com | 1 |
| 2 | test2@gmail.com | 2 |
dbo.RegistrationResults
| Id | ValidationOutcome |
|---|---|
| 1 | Awaiting confirmation |
| 2 | Confirmed |
dbo.UserNotes
| Id | Message | RegistrationResultFk |
|---|---|---|
| 1 | it's a test | 1 |
| 2 | it's a test 2 | 2 |