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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / CDS Enity Primary Key ...
Power Apps
Unanswered

CDS Enity Primary Key field Auto-Generated vs Derived Key

(1) ShareShare
ReportReport
Posted on by 10

When I create a CDS Entity using DataFlow, in the Field Mapping there is a choice of Assigning an Auto-Generated Unique primary name field, or I can define my own Key by selecting from existing fields.

In addition there is an Alternate key field.

 

Can someone explain the purpose or best practice of these 3 options?

 

I do have a derived unique identifier per record. Should I use that as the Primary or the Alternate key?

I wish to have my entity loaded as a 'full load' initially, then subsequent daily refreshes would have a subset of new/modified records.

Which of the keys (Primary and/or Alternate) would be used to determine which records are net new vs updates?

 

Thank you

I have the same question (0)
  • MichaelFP Profile Picture
    1,847 Super User 2025 Season 2 on at

    H! @s-roberts 

     

    The primary key, is main field that Common Data Service, in Common Data Model, uses for identify uniquely the record across the instance. It is a Guid value. This field internally is always used for doing any CRUD operations and other operations in relationships. And is not possible to change this type.

    The alternative key is used if your business has a need to identify the record by another custom information. Like a driver's license for example. On CDS,  will validate first in your alternative key and after will use the primary for the operations.  So if you want to have unique records based on information input by the user, an alternative key is the best approach. You do not need a plugin to validate and try to find if already has a record with the same value. 

    Another great thing is that increases the performance on the queries

     

    If you want more information please, go through this link -> https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/define-alternate-keys-reference-records



    Please mark as solution if help you.

  • s-roberts Profile Picture
    10 on at

    When creating the entity from the Dataflow, there is an option to leave the Primary Key as the Auto-generated default, or you can use a field from your entity.  If I leave it as the auto-generated guid, how does it determine which records to update in the next refresh?

     

    If I override this default (not use the GUID) and use a key that I have defined, what is the purpose of the Alternate key?keys.JPG

  • MichaelFP Profile Picture
    1,847 Super User 2025 Season 2 on at

    Primary Name, its a string field that when you create entity CDS create and is the field that is displayed when you select a record on the lookup field. The data flow will generate for you, a random content to fill this field. It´s different from Primary Key. Behind the scenes, CDS will always generate Guid for the Primary Key of your entity. Will not override the guid, you have an option to use alternative key if you need a field to use like the primary key. 

     

    Another example, our data source it´s a database, and you table has a column that is type integer and is the primary. So if you want to easily find the record based on the same value that database column use as primary key, you will use "alternative key" in CDS. 

     

    Example
    Entity A (mfp_account)

    mfp_accountid -> Primary Key Create by CDS

    mfp_id_database -> custom field create by me

     

    if I put mfp_id_databse as the alternate key, I can do an update on this entity directly, I don't need to take care to know the Guid, CDS takes this task for us.

    In the documentation has more information about it -> https://docs.microsoft.com/pt-br/powerapps/developer/common-data-service/use-alternate-key-create-record

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard