开发者

Entity Framework Configuration Question (EF Code-First)

开发者 https://www.devze.com 2023-03-19 23:56 出处:网络
I\'m using table per hiearchy for the following model: Story (base class) - Individual Story (sub class)

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!


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消