Entity and attribute naming conventions
Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online
In Microsoft Dynamics 365, the programming method you use to access data determines the naming convention you use.
When you use the strongly typed classes generated by the code generation tool (CrmSvcUtil.exe) or when you use the OrganizationServiceContext class, you’re programming with early binding. With early-binding programming, you use the schema name of an entity or attribute. Schema names are defined in the Microsoft.Xrm.Sdk.Metadata.EntityMetadata.SchemaName and Microsoft.Xrm.Sdk.Metadata.AttributeMetadata.SchemaName properties.
The following code example shows early binding and uses schema names.
// Create new account using early binding and a context object.
AWCServiceContext context = new AWCServiceContext(_serviceProxy);
Account account = new Account()
{
Name = "Contoso Services Extensions",
EMailAddress1 = "contoso-Ext@contoso.com"
};
// Create an account record.context.AddToAccountSet(account);
context.SaveChanges();
When you use the Entity class, you are programming with late binding. With late-binding programming, you use the logical name of an entity or attribute. Logical names are defined in the Microsoft.Xrm.Sdk.Metadata.EntityMetadata.LogicalName and Microsoft.Xrm.Sdk.Metadata.AttributeMetadata.LogicalName properties.
The following code example shows late binding and uses logical names.
//Create new account using late binding and the Entity class.
Entity accountentity = new Entity("account");
accountentity["name"] = "Contoso Services Extensions";
accountentity["emailaddress1"] = "contoso-Ext@contoso.com";
// Create an account record.
_accountId =_serviceProxy.Create(accountentity);
To find the logical and schema names for each entity, see the metadata for each entity. To view the entity metadata for your organization, install the Metadata Browser solution described in Browse the metadata for your organization. You can also view the metadata for an uncustomized organization in the Excel file called EntityMetadata.xlsx included in the top-level folder of the SDK download. The generated strongly-typed classes file also shows the logical and schema names for each entity and attribute.
See Also
Use Microsoft Dynamics 365 services in code
Assemblies included in the Microsoft Dynamics 365 SDK
Use the early bound entity classes in code
Use the late bound entity class in code
Introduction to entity attributes in Microsoft Dynamics 365
Microsoft Dynamics 365
© 2016 Microsoft. All rights reserved. Copyright