ERROR applying foreign key constraints

Hi
We are upgrading from imis 10.6.30.7 to 15.1.1.2998 and continue to get the same error when running the install process. The install fails at step 58. See the following error
Validating data for Foreign Key Constraint application...

FK_UserMain_ContactMain cannot be applied because 1 rows do not exist

Step 58 Done.

Applying Foreign Key Constraints ...

*** ERROR applying foreign key constraints ***

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint
"FK_UserMain_ContactMain". The conflict occurred in database "iMIS", table
"dbo.ContactMain", column 'ContactKey'.
Msg 547, Level 16, State 1, Server SERVERTEST5, Line 6

*** UPGRADE PROCESS ENDED WITH ERRORS !!! ***

IMIS150DBUpgrade.cmd Process Exited
Elapsed Time: 00:11:06

Elapsed Time for all scripts run: 00:11:06

Can anyone help

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Orphan Row

It looks like you have a row in UserMain that does not have a corresponding row in ContactMain (in other words, there is an "orphan" row in UserMain that needs to be removed ... or a ContactMain row needs to be added for it).

Restore your database to its pre-upgrade (10.6) state, and issue this query:

SELECT *
FROM [dbo].[UserMain]
WHERE [UserKey] NOT IN (SELECT [ContactKey] FROM [dbo].[ContactMain])

This should show you the row that's the problem.

You should then be able to just DELETE FROM [dbo].[UserMain] WHERE [UserKey] = 'key', where "key" is the UserKey in the row listed by the above query.