Export (0) Print
Expand All

Entity and attribute naming conventions

Applies To: CRM 2015 on-prem, CRM Online

[This topic is pre-release documentation and is subject to change in future releases.]

In Microsoft Dynamics CRM, 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

Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.
Show:
© 2015 Microsoft