Sunday 23 August 2009

Navigation Properties and Entity Inheritence

Symptom
Navigation Properties are not supported on derived entity types
The full error message reads something like this:
Navigation Properties are not supported on derived entity types. Entity Set [BaseSetName] has a instance of type [DerivedType], which is an derived entity type and has navigation properties. Please remove all the navigation properties from type [DerivedType].
Cause

Sounds straight forward enough, right? Remove the navigation properties from the derived type. Hang on, my navigation properties are specific to the derived type, not the base type. Does this mean I can't navigate from the derrived type at all? As it turns out, that's right - you can't (see Microsoft's response). So, the equation as I see it as follows:
  • You can use inheritance in your EF model but not with data services. You need to write the WCF service and client proxy by hand.
  • Or, you can remodel you entities without inheritance and use ADO.NET data services.
Apparently this is going to be fixed in v2. I am disappointed by this: for me, a big factor in using EF is the support for entity inheritance. Not happy!

No comments: