Reputation: 5546
I have entity A. Entity B inherits entity A. For entity B there are o propertis generated by entity framework for accessing it's content. How can access entity B?Do I have to provide my own methods, or can I force EF to cretae them?
what I do is: B inhirits A context.A - have access to entity A
but context.B does not exist. methods are not generated for accessing entity B.
Upvotes: 0
Views: 127
Reputation: 364279
When you run queries on context.A it will return entities from whole inheritance hierarchy. So the result of context.A.ToList()
will be all As and Bs. If you want to query only derived type you can use context.A.OfType<B>().ToList()
Upvotes: 2