0

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!

0

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

Comments

0

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.

4 Comments

sorry, i had to edit my question. I added a property to Individual Story that matched the exact column name and then I added one to team story with a different name. I added the mapping but failed. Does my edited question change your resonse?
@Marco: No, it shouldn't change it. I'll need to know the actual error you're getting to be able to help.
The column name is TelleId and the error is "Invalid column name 'TelleId1'." and here is my mapping: modelBuilder.Entity<TeamStory>().Property(p => p.TeamLeaderUserId).HasColumnName("TelleId");
@Marco: Are you using code-first? If so, I can't help you; you might want to note that in the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.