Dataverse for Architects: Designing with Alternate Keys in Mind
In Microsoft Dataverse, data integrity and uniqueness are critical for building scalable, enterprise-grade apps. While Dataverse ensures every row has a system-generated GUID as its primary key, real-world business scenarios often require natural identifiers like Customer Numbers or Email Addresses to enforce uniqueness.
This is where Keys in Dataverse—both primary and alternate—become essential. In this guide, we’ll deep dive into:
- What keys are in Dataverse
- Technical details for developers
- Strategic insights for architects
- Real-world use cases
- Limitations and best practices
What Are Keys in Dataverse?
A key in Dataverse defines a column (or set of columns) that enforces uniqueness in a table.
This means no two rows can have the same value for the key column(s).
There are two types of keys in Dataverse:
Primary Key (System-Managed)
- Every Dataverse table automatically includes a GUID primary key (e.g., `contactid`, `accountid`).
- Assigned automatically when a record is created.
- Immutable – once created, it never changes.
Example:
`accountid = 15f2b5d0-34d1-4a18-8e42-44c9b33e43a2`
Alternate Keys (User-Defined)
- Alternate keys let you enforce uniqueness on one or more columns of your choice.
- They’re great for business identifiers like Customer Numbers, Emails, or SKU Codes.
How to Create Alternate Keys
Step-by-Step
1️⃣ Go to [Power Apps Maker Portal](https://make.powerapps.com)
2️⃣ Select your table (e.g., Account) → Keys tab
3️⃣ Click + New Key
4️⃣ Choose column(s) to define as unique
5️⃣ Save and Publish
Supported Column Types:
- Single Line of Text (max 450 chars)
- Whole Number
- Decimal Number
- Lookup (relationships)
Best Practices
- Use alternate keys for external system IDs (e.g., SAP Customer ID).
- Prefer single-column keys for simplicity and performance.
- Avoid using fields that frequently change as keys.
- For composite keys, keep the number of columns minimal.
- Always test large imports or API calls for duplicate key errors.
Real-World Use Cases
- 🛒 E-commerce: `SKU` as alternate key for Product table.
- 🏥 Healthcare: `PatientID` as alternate key for Patient table.
- 📦 Supply Chain: Vendor or Purchase Order Numbers for integration with ERP.
- 📧 CRM: `emailaddress1` for deduplication of Contacts.
Summary
Keys in Dataverse are a must-have tool for both developers and architects:
- Developers – For clean APIs, upserts, and cross-system references
- Architects – For maintaining data integrity and future-proofing solutions
By mastering keys, you can build enterprise-grade, scalable solutions with confidence.
Published on:
Learn more