web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Getting error after synchronize database

(0) ShareShare
ReportReport
Posted on by

at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.<>c.<RunPartialTableSync>b__18_1(Tuple`2 result)
--- End of inner exception stack trace ---
--- End of stack trace from previous location where exception was thrown ---
AND dict.fieldid != tfid.id
AND dict.fieldid > 0 -- ignore table definition row
AND dict.tableid = tfid.rootid
AOS database sync failed. Microsoft.Dynamics.AX.Framework.Database.TableSyncException: Incremental sync did not complete successfully. Error: AggregateException:One or more errors occurred.
at Microsoft.Dynamics.AX.Data.Management.DBExecute.ExecuteDDLWithNewTransaction(String commandText)
at Microsoft.Dynamics.AX.Data.Management.DBExecute.ThrowOnSqlExecuteException(SqlException e, String commandText)
at Microsoft.Dynamics.AX.Data.Management.ManagedSyncTableWorker.AlignSqlDictionaryFieldIdsForTable(Int32 tableId)
at Microsoft.Dynamics.AX.Data.Management.ManagedSyncTableWorker.ExecuteModifyTable(AxTable newTableSchema, AxTable oldTableSchema, Int32 tableId)
at Microsoft.Dynamics.AX.Data.Management.ManagedSyncTableWorker.ModifyTable(AxTable newTableSchema, Dictionary`2 oldTableSchemaDictionary)
at Microsoft.Dynamics.AX.Data.Management.ManagedSyncTableWorker.SyncIncremental(IList`1 requests, IList`1 dropEntities)
at Microsoft.Dynamics.AX.Data.Management.ManagedSyncTableWorker.TryExecuteModifyTableViaAlterTable(AxTable newTableSchema, HashSet`1 ignoreIndexListCache, IncrementalSyncTableSchemaBuilder tableSchemaBuilder)
at Microsoft.Dynamics.AX.Data.Sql.SqlDataAccessManager.<ExecuteNonQuery>b__30_0(SqlCommand c)
at Microsoft.Dynamics.AX.Data.Sql.SqlDataAccessManager.ExecuteSql[T](SqlCommand cmd, Func`2 sqlFunc)
at Microsoft.Dynamics.AX.Data.Sql.SqlDataAccessManager.HandleException(ExceptionDispatchInfo edi, SqlExecutionInfo execInfo)
at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.ExecuteWithinAOS(SyncOptions syncOptions, String sqlConnectionString, IMetadataProvider metadataProvider, Func`1 func, Action`1 errorHandler)
at Microsoft.Dynamics.AX.Framework.Database.Tools.LegacyCodepath.RunPartialTableSync(SyncOptions options, String sqlConnectionString, IMetadataProvider metadataProvider)
at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialSync()
at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.PartialTableViewSync()
at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.Run(String metadataDirectory, String sqlConnectionString, SyncOptions options)
at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.RunSync()
at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.SqlCommandExtensions.<>c__DisplayClass1.<ExecuteNonQueryWithRetry>b__0()
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Database execution failed: Violation of PRIMARY KEY constraint 'I_65518FIELD'. Cannot insert duplicate key in object 'dbo.SQLDICTIONARY'. The duplicate key value is (23233, 36, 1, 0).
Database synchronization failed. You may have to do a full build of the package and all of its dependent packages.
FROM DBO.TableFieldIdTable tfid
Inner exceptions:
INNER JOIN DBO.SqlDictionary dict
Managed Sync Table Worker encountered an exception, but is continuing because ContinueOnError is true. Table Sync Failed for Table: VendorDataStaging. Exception: System.InvalidOperationException: Database execution failed: Violation of PRIMARY KEY constraint 'I_65518FIELD'. Cannot insert duplicate key in object 'dbo.SQLDICTIONARY'. The duplicate key value is (23233, 36, 1, 0).
ON dict.name = tfid.name
SET fieldId = tfid.id
syncengine.exe exited with code -1.
The statement has been terminated.
UPDATE DBO.SqlDictionary
WHERE tfid.rootid = 23233; ---> System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'I_65518FIELD'. Cannot insert duplicate key in object 'dbo.SQLDICTIONARY'. The duplicate key value is (23233, 36, 1, 0).
WHERE tfid.rootid = 23233;.

I have the same question (0)
  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    As the first thing, I would follow the advice in the error message ("You may have to do a full build of the package 'Kriz' and all of its dependent packages."). It might help.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    303,679 Super User 2026 Season 1 on at

    Hi Kanchan,

    The sync job creates new fields and tables when needed in the SQL database. The error mentions that it can't create a duplicate record in the SQLDictionary table which is a table between the meta data and SQL.

    This can be caused by e.g. an already existing field in another model or if you moved a field to another model.

    Probably you can get a similar error if you change data types from e.g. string to integer.

    Can you check what changes you made and if this could be caused by one of the reasons mentioned above?

  • Community Member Profile Picture
    on at

    Thanks for your suggestion.

    But after full package build errors still comes.

  • WillWU Profile Picture
    22,363 on at

    Hi Kanchan rawat,

    Error Managed Sync Table Worker encountered an exception, 
    but is continuing because ContinueOnError is true. 
    Table Sync Failed for Table: Kriz_VendorDataStaging. 
    Exception: System.InvalidOperationException: Database execution failed: Violation of PRIMARY KEY constraint 'I_65518FIELD'. 
    Cannot insert duplicate key in object 'dbo.SQLDICTIONARY'. The duplicate key value is (23233, 36, 1, 0).

    It seems that the Fieldid of your custom field in the TABLEFIELDIDTABLE table is different from the fieldID in the SqlDictionary table and you need to manually update the FieldID in the SqlDictionary table. See:sinedax.blogspot.com/.../violation-of-primary-key-constraint.html

  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    If you're unable to build your solution, you'll need to fix the compilation errors. Don't bother trying to use the application (including synchronizing it with database) until you compile it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans