实体框架配置问题(EF代码优先) [英] Entity Framework Configuration Question (EF Code-First)

查看:106
本文介绍了实体框架配置问题(EF代码优先)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



故事(基础类)
- 个人故事(子类)
- 小组故事(子类)



我在表中的列,我想在两个派生类型之间共享,但我想在每个类中命名它不同。这可能吗?我尝试了一些不同的东西,但是无法正常工作(可以挖掘正确的异常tomrrow在工作中,如果需要)。



谢谢!

解决方案

不可以。该列映射到基类中的属性,此属性在子类中派生。您不能更改派生类中的属性名称,而EF不允许在派生类中映射共享属性(它们必须映射到基类中)。


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

这篇关于实体框架配置问题(EF代码优先)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆