Have you noticed that the generated early-binding classes always have 2 ID properties? For example, the Account class would have Id and AccountId. The Contact class would have Id and ContactId.
Which property should you use in early-binding programming?
Well, if you are writing a LINQ query, do not use the Id property, and use the AccountId property instead. Using the Id property in your LINQ query will result in an exception with the cryptic message “attributeName“. Digging a bit deeper, you will see that the underlying exception message is “System.ArgumentNullException: Value cannot be null.\r\nParameter name: attributeName.”
While in the generated early-binding class both properties are tagged with the [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute(“accountid”)] attribute, I could only get the LINQ query to work with AccountId. I suspect that the CRM LINQ parser does not look at this attribute when parsing the LINQ query.