Web API EntityTypes
Within the CSDL $metadata document, immediately below the Service namespace there's a list of EntityTypes. An entity type is a named structured type with a key. It defines the named properties and relationships of a table.
EntityType elements usually have the following attributes:
||The name of the type; the LogicalName for the table.|
||The EntityType that the type inherits from.|
For example, this XML element is the
EntityType for the
account entity, excluding properties and navigation properties.
<EntityType Name="account" BaseType="mscrm.crmbaseentity"> <Key> <PropertyRef Name="accountid" /> <!--The name of the primary key --> </Key> <!--Properties and navigation properties removed for brevity--> <Annotation Term="Org.OData.Core.V1.Description" String="Business that represents a customer or potential customer. The company that is billed in business transactions." /> </EntityType>
Except for three exceptions, all entity types have the following child elements:
||Contains details about a property of the EntityType. See Web API Properties.|
||Contains details about a relationship with this EntityType. See Web API Navigation Properties|
Special entity types
There are three entity types that don't have
This element defines a common abstract type for any table that contains business data.
<EntityType Name="crmbaseentity" Abstract="true" />
Because all entity types that contain business data inherit from
crmbaseentity is referenced when a value isn't specific to one table.
This element defines an entity type that inherits from
crmbaseentity but is also an OData OpenType.
<EntityType Name="expando" BaseType="mscrm.crmbaseentity" OpenType="true" />
An expando entity type can be used as a parameter to an action, or as a response property from a function or action.
More information: Use open types with custom APIs
This element exists near the bottom of the $metadata document:
<EntityType Name="crmmodelbaseentity" Abstract="true" />
This element defines a common abstract type for any schema definitions. It's the base type for another abstract base class used for table definitions. Unless you want to create and modify tables, columns, and relationships using Web API you don't need to use entity types that inherit from this type. More information: Use the Web API with table definitions.
For business data, there are two more abstract entity types that inherit from
||Any table that is configured as an activity inherits from the
When working with table definitions, there another hierarchy of inheritance. MetadataBase entity type inherits from the abstract
crmmodelbaseentity to provide common
HasChanged properties. More information: Use the Web API with table definitions.
When an entity type has any alternate keys defined, there's an
Annotation that describes the properties that are involved in the alternate key definition.
The following example shows the annotation when the
account entity has been configured to enable the
accountnumber property as an alternate key.
<Annotation Term="OData.Community.Keys.V1.AlternateKeys"> <Collection> <Record Type="OData.Community.Keys.V1.AlternateKey"> <PropertyValue Property="Key"> <Collection> <Record Type="OData.Community.Keys.V1.PropertyRef"> <PropertyValue Property="Alias" String="accountnumber" /> <PropertyValue Property="Name" PropertyPath="accountnumber" /> </Record> </Collection> </PropertyValue> </Record> </Collection> </Annotation>
More information: Retrieve record using an alternate key
Learn about properties.
Web API types and operations
Web API Service Documents
Web API Properties
Web API Navigation Properties
Web API Actions
Web API Functions
Web API Complex and Enumeration types
Use the Dataverse Web API