EF: selecciona todas las entidades de la subclase (herencia)

I am using the Database first approach and DbContext. I have several inheritance structures (TPH) in my data model. But DbContext only creates one DbSet for the base class, and none for the subclasses. How should I retrieve all Entities of a specified subclass?

I cannot write queries based on the mapping criteria, as i had to remove those fields from the data model.

Can I simply add a new DbSet to the Entities class (partial class) ?

preguntado el 22 de mayo de 12 a las 07:05

1 Respuestas

You can add new properties returning DbSets of your derived types into context's partial class or you can simply use OfType<DerivedType>() operator when querying sets created by the code generator.

contestado el 22 de mayo de 12 a las 09:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.