Mendix manages this as part of the domain model. You don’t have to do anything. I hope this helps.
As Roberts says, Mendix handles this for you.
Each record of a entity will get its own unique ID. This ID is used to set references.
See https://docs.mendix.com/refguide/associations/