If you start implementing WCF Data Services, sooner or later you will certainly see following error when calling the OData feed:
“On data context type 'XXXXX’, there is a top IQueryable property 'XXXX' whose element type is not an entity type. Make sure that the IQueryable property is of entity type or specify the IgnoreProperties attribute on the data context type to ignore this property.”
This can mean two things. Either you have a property that cannot be processed by the Entity Data Model used by OData or OData could not find a primary key for your class.
OData requires a primary key for every resource. If you use the reflection based provider, it uses one of the following mechanisms to find the primary key:
- via the [DataServiceKey] attribute
- by looking for a "FooID" property, where the type is called "Foo"
- by looking for an "ID" property
Important to know is that this convention is case-sensitive: "FooId" won't work without a [DataServiceKey].