You receive the following error when importing Inventory: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_MCCP_Media"
SummaryWhen attempting to manually import inventory, you may receive the following error: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_MCCP_Media"
SymptomsWhen attempting to import an inventory (*.ndi) file into Inventory Manager 2015, you may receive the following error:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_MCCP_Media" . The conflict occurred in database "IM, table "dbo.Media", column "MediaID". The statement has been terminated.
Unexpected exception in importer
CauseThis is caused by having 0 (zero) rows in the dbo.Media table in the Inventory Manager database. When the import process attempts to insert rows into the dbo.MediaContainsPackagePath it attempts to cross reference the MediaID column with the dbo.Media table and because this table is empty, the import fails.
ResolutionThe resolution to this is in two parts.
Firstly, we have to insert a record into the dbo.Media table. To do this, please run the following on the IM database:
SET identity_insert Media ON
INSERT INTO Media (MediaID, Title, MediaTypeID, Location)
VALUES (1, '', 1, '')
SET identity_insert Media OFF
Secondly, we need to remove a step in the 'Daily IM Data Maintenance' SQL job. This job calls a Stored Procedure, and we need to remove a step which deletes unused data from the Media table:
Please run the attached DBMaintenance.sql file on the IM database. This will drop and re-create the Stored Procedure with this line removed.
WorkaroundPlease see above for resolution.