Data entity errors


My previous article was about data entities.
After that, I started to put my knowledge into work and encountered some errors.
I didn’t find too much information about them so I decided to write a post about data entity errors.

Error after adding range


When I try to add a range to my data source, Visual Studio won’t let me build the project. The following error message shows up:
A local variable named ‘IsPrimary’ cannot be declared in this scope because it would give a different meaning to ‘IsPrimary’, which is already used in a parent or current scope to denote something else.


The ‘IsPrimary’ field was one of the entity’s fields. Renaming the range or the field did not solve the error.
Since it was a NoYes field, it was not mandatory to be in the entity field list because the range filtered the value already. I deleted the ‘IsPrimary’ field from the field list and now the project can be built without errors.

Errors after project rebuild


After you modify an entity that’s already been in the Data entity list – or in the DMFEntity table – and then you rebuild the project, you’ll get something similar to the following error list.

  • Error at Dynamics.AX.Application.DmfDataPopulation.`syncEntityMetadata(StringCollection dataEntityViewCollection, StringCollection compositeEntityList) in xppSource://Source/ApplicationFoundation\AxClass_DmfDataPopulation.xpp:line 996.’ on category ‘Error’.
  • at Dynamics.AX.Application.DmfDataPopulation.syncEntityCreate(DictDataEntity dictDataEntity, Boolean useTargetEntityName)
  • at Dynamics.AX.Application.DmfDataPopulation.syncEntityUpdate(DMFEntity _dmfEntity, DictDataEntity _dictDataEntity)
  • Infolog diagnostic message: ‘Cannot create a record in Entity (DMFEntity). Entity: Purchase Orders, Entity.
  • Database synchronization failed. You may have to do a full build of the package ‘Package’ and all of its dependent packages.
  • The record already exists.’ on category ‘Error’.


You can delete the affected entities from the Data Entities list. (System Administration – Data management node.) If the entity has corresponding data projects, delete them first. Then try deleting the entities again and rebuild the project.
This solution solves the errors only until the next rebuild.
The data entity’s label causes the real problem here. System data entities usually use the same label as their main data source’s label. Your data entity can easily get the same label if your entity was made with the help of the wizard.

Data entity not shown in Data entities list


Even after refreshing data entities, the custom data entity was still not shown in the list. However, it could be displayed by OData.


The custom entity had the same label as a system entity that already existed. I created a new different label for it and after that it was displayed in the data entities list.

Failed to parse data entity view queries for following data entities


I imported a non-standard table from an old version of AX (AX 4.0) through xml. Then I created a data entity and used this table as one of the datasources. I didn’t get any errors when modifying properties and saving the object, but when I built and synchronized it, I got the following error list.

  • Error                     syncengine.exe exited with code -1.                                     
  • Error                     Microsoft.Dynamics.AX.Framework.Database.Synchronize.DataEntitySyncException: Failed to parse data entity view queries for following data entities: <EntityName>
  • Error                     at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.RunSync() 
  • Error                     at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.Run(String metadataDirectory, String sqlConnectionString, SyncOptions options)       
  • Error                     at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.FullSync()  Error                     at Microsoft.Dynamics.AX.Framework.Database.Tools.SyncEngine.DataEntityTriggerSync()
  • Error                     at Microsoft.Dynamics.AX.Framework.Database.Tools.DataEntityTriggerSync.RunSync() 


After looking around on professional forums, I stumbled upon a solution that solved my issues. It suggested that this error might be caused because of table relations are not set up correctly and to check the cardinalities of the relations.
I noticed that on the table I imported, cardinality properties were not filled in. After filling them out correctly, the errors were gone and the data entity was working.


Fixing errors can be time consuming and sometimes frustrating.
I hope I could help you finding the solution that you were looking for.

Leave a Reply

Your email address will not be published. Required fields are marked *