Natural key not found error during data entities creation

While creating Data Entites in Dynamics 365 for Operations (AX 7) it may happen to obtain an error: “The natural key for the table xyz was not found”. This error just tells that the table (related to the data entity) is missing a human readable key (that of course can’t be its RecId).

So, for example the SalesTable table has the SalesId column that can be used as a natural key in a related data entity, but some other tables haven’t similar columns. Since for creating a data entity it is normal to use the functionality of Visual Studio, which creates it automatically, I tried to investigate how Visual Studio searches for a natural key for a specific table.

  1. First of all Visual Studio tries to find a key by analyzing columns which belong to the Replacement Key index.
  2. Then it analyze columns which belong to the Primary Key index.
  3. Next step is to analyze columns which belong to the Alternate Key indexes.
  4. Last chance is to analyze columns which are in the AutoIdentification FieldGroup.

If none of these four steps let Visual Studio to find a valid natural key the previous error message is shown.

Knowing the way Visual Studio works can help in deciding how to add a natural key to the table by using the proper extension.

Leave a comment