Dotmim.Sync: MERGE conflict in DMS 7.0

The following exception is thrown by SyncResult syncResult = await syncAgent.SynchronizeAsync();

The MERGE statement conflicted with the FOREIGN KEY SAME TABLE constraint "FK_Jobs_OrderDetails". The conflict occurred in database "AU13237", table "dbo.Jobs", column 'JobId'. The statement has been terminated.

All jobs must appear on an order detail. Not all order details include a job.

On SQL Server the job on the order details table is defined [JobId] [uniqueidentifier] NULL Order detail on the jobs table is defined [Jobs].[OrderDetailId] [uniqueidentifier] NOT NULL

Foreign keys

ALTER TABLE [dbo].[Jobs]  WITH CHECK ADD  CONSTRAINT [FK_Jobs_OrderDetails] FOREIGN KEY([OrderDetailId])
REFERENCES [dbo].[Jobs] ([JobId])

ALTER TABLE [dbo].[OrderDetails]  WITH CHECK ADD  CONSTRAINT [FK_OrderDetails_Jobs] FOREIGN KEY([JobId])
REFERENCES [dbo].[Jobs] ([JobId])

This error does not occur in DMS 6.2. We’ve rolled back.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Thank you @Mimetis for all your help on this. DMS 0.7.2 is working like a charm

You wrote

ALTER TABLE [dbo].[Jobs] ADD  CONSTRAINT [FK_Jobs_OrderDetails] FOREIGN KEY([OrderDetailId])
REFERENCES [dbo].[Jobs] ([JobId])

But it’s incorrect. I guess it’s more

ALTER TABLE [dbo].[Jobs] ADD CONSTRAINT [FK_Jobs_OrderDetails] FOREIGN KEY([OrderDetailId]) 
REFERENCES [dbo].[OrderDetails] ([OrderDetailId])