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 / Dataverse SDK - Create...
Power Apps
Answered

Dataverse SDK - Create a table with an int primary key

(0) ShareShare
ReportReport
Posted on by 35

Is it possible to create an entity with an Int primary key? Below is my request to create the entity but you HAVE to use the StringAttributeMetadata. It does not allow you to use IntAttributeMetadata. Does this mean that ALL primary keys have to be strings? Thanks in advance for any help.

 

var createEntityRequest = new CreateEntityRequest()
{
Entity = new EntityMetadata()
{
SchemaName = $"{schema}_{entityName.ToLowerInvariant()}",
DisplayName = new Label(displayName, 1033),
DisplayCollectionName = new Label(displayCollectionName, 1033),
Description = new Label(description, 1033),
OwnershipType = OwnershipTypes.UserOwned,
IsActivity = false
},
PrimaryAttribute = new StringAttributeMetadata
{
SchemaName = $"{schema}_{primaryKeyAttributeName.ToLowerInvariant()}",
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
MaxLength = 100,
FormatName = StringFormatName.Text,
DisplayName = new Label(primaryKeyAttributeName, 1033),
Description = new Label($"The primary column for the {displayName} table.", 1033)
}
};

I have the same question (0)
  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    The Primary Attribute can be only a string. That is a platform limitation.

  • Verified answer
    Guido Preite Profile Picture
    1,488 Super User 2024 Season 1 on at

    the primary key is always a Guid, the primary attribute is always a string.

    However you can create an int column and create a key containing only this int column, so it acts like a key.

    to fill automatically this column you will need a plugin, but at least is doable.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard