Recently I was asked to create a data entity for the AssetTrans table in Dynamics 365 Finance and Operations. There isn’t a stock entity for AssetTrans, so I turned to the Data Entity Wizard to streamline the entity creation process:
It was then that I ran into the dreaded “The natural key for the table was not found” error in the Dynamics 365 Data Entity Wizard:
The problem is that the AssetTrans table uses RecId as its primary index, and the Data Entity Wizard doesn’t support tables with a RecId-based primary key. Further, we cannot add a new index to AssetTrans and set it as the natural key via a table extension, as the Primary Index parameter is disabled in table extensions.
When faced with this issue in the past I have taken a manual approach: find an existing data entity, duplicate it, and replace its contents with references to the table I wanted to specify in the wizard. This approach also required me to manually create the staging table and security privileges—not a huge burden, but significantly more work than letting the wizard take care of it for me!
This time, I tried something new. I duplicated the AssetTrans table as MyAssetTrans and created a new non-RecId based primary index for it:
I then ran the Data Entity Wizard again, using the MyAssetTrans table as the primary datasource:
This time, the wizard proceeded to the next step of selecting the fields I wanted included in the entity:
Once the wizard completed, I had my data entity, staging table, and security privileges, but I still had a problem: the entity was based on MyAssetTrans, not AssetTrans. Fortunately, all I had to do was change the Data Source on the data entity from MyAssetTrans to AssetTrans:
And I had my AssetTrans entity ready to go. If you’ve run into this problem, I hope this article helps! If you need more assistance, we have a great support team. Contact us to learn more.