Exposing entitySets using inheritance RRS feed

  • Question

  • I have an ef 4.1 model that was built using model first.  I have a PERSON entity which has a derived TEEN entity (there are other derived types as well). and I am using table per type.

    While I can see a teen entity, I only get one entity set - people, but no teens entity set.  Is there a way to expose teens as an entity set ?
    Tuesday, August 23, 2011 3:01 PM

All replies

  • The tools do not support this. The easiest way would be to just declare a partial class for the context and add the derived sets in there.

    thank you,


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, August 23, 2011 10:38 PM
  • I tried this but cant figure out how to get wcf data services (odata) to expose this new set.



    I also tried changing to dbContext and this did not help as I ran into this error

    The server encountered an error processing the request. The exception message is 'Property 'people' and 'teens' are IQueryable of types 'ncsyOdata.person' and 'ncsyOdata.teen' and type 'ncsyOdata.person' is an ancestor for type 'ncsyOdata.teen'. Please make sure that there is only one IQueryable property for each type hierarchy.'.


    This seems to preclude using inheritence!

    Tuesday, August 30, 2011 2:00 AM