AX7: Fix “Natural key not found” when creating a Data Entity

While creating a few Data Entities in Dynamics 365 for Operations (AX 7) I crashed in the “Natural key not found” error. This error just tells us, that our table is missing a key, that is not a RecId. In this post I want to show you how to setup a Data Entity and also how to resolve that error.

Setting up a Data Entity in Dynamics 365

For this post I created a simple table and simply added 3 fields.

D365 Natural Key Not Found Setup a Table

Next I clicked “Add New Item” after right clicking my project. I selected “Data Entity” from “Data Model” and set a name for my new Data Entity.

D365 Natural Key Not Found Create a Data Entity


After hitting “Add” the following Wizard comes up. Here I added my new table as “Primary datasource” and set a category (Data entities categories).

D365 Natural Key Not Found Setup a Data Entity

If I hit “Next” here, the error we want to solve shows up. “The natural key for the table TableTest was not found”.

D365 Natural Key Not Found Error

Solving the “Natural key not found” error

The table I set up earlier is missing an index, so we have to add one.

D365 Natural Key Not Found Missing Index

In this example I added a new Index, named it “UnqIdx” and added all my fields to it.

D365 Natural Key Not Found Creating Index

Next I set the new Index up as “Primary Index”.

D365 Natural Key Not Found Set Index

If we go back to the Data Entity Wizard and hit “Next” again, it should work out and we are getting to the “Add fields” step.

D365 Natural Key Not Found Finish Data Entity

If you hit finish here, the new Staging Table should show up, also the new Data Entity of course.

D365 Natural Key Not Found Finished Data Entity

Now we have solved the “Natural key not found” and also set up a new Data Entity.


You may also like...