Marco
Marco

Reputation: 2473

Entity Framework Configuration Question (EF Code-First)

I'm using table per hiearchy for the following model:

Story (base class) - Individual Story (sub class) - Team Story (sub class)

I column in my table that I want to share between both derived types, but I would like to name it differently in each class. Is this possible? I tried a few different things but could not get it to work out correctly (can dig up the exact exception tomrrow at work if need be).

Thanks!

Upvotes: 0

Views: 207

Answers (2)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

No it is not possible. The column is mapped to property in the base class and this property is derived in sub classes. You cannot change the name of property in derived class and EF doesn't allow mapping shared properties in derived classes (they must be mapped in the base class).

Upvotes: 1

Adam Robinson
Adam Robinson

Reputation: 185593

If by "share", you mean that you'd like both subclasses to use that database field (but NOT the base class) just with different names, that should work as long as it's not the discriminator column. Just create scalar properties on each subtype and map the appropriate property to the common field.

Upvotes: 0

Related Questions