Question

My trivial EDMX has a base entity along with two entities that inherit from it...

        <>-------- UserEntity
EntityBase
        <>-------- CustomEntity

...this automatically creates three ObjectSet properties on the generated ObjectContext...

public ObjectSet<EntityBase>   EntityBases {...}
public ObjectSet<UserEntity>   UserEntities  {...}
public ObjectSet<CustomEntity> CustomEntities  {...}

...which is great. I can then use any of these three in my Linq To Entities. I actually want to use self tracking entities and so set the Code Generation Strategy to None. Then add the self tracking T4 templates. But the newly generaed ObjectContext only has the following...

public ObjectSet<CustomEntity> EntityBases {...}

...but the inherited entities of UserEntities and CustomEntities are nowhere to be seen! Can the self tracking entities T4 handle table per type? Surely it can? What gives?

Was it helpful?

Solution

That is correct behavior. You will get ObjectSet only for base type and this set is used to access all inherited types as well. If you want to get just UserEntity instances you will use .OfType<UserEntity>() extension method, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top