代码优先 - 如何在TPH继承中指定鉴别器列 [英] Code First - How to specify discriminator column(s) in TPH inheritance

查看:75
本文介绍了代码优先 - 如何在TPH继承中指定鉴别器列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先使用代码(CTP 3)创建TPH继承来创建我的edmx。以下代码是我的情况的简化示例:
I am to do TPH inheritance using code first (CTP 3) to create my edmx. The following code is a simplified sample of my situation:

推荐答案

验证失败,因为属性Student.Age和Teacher.Age映射到同一商店 - 侧栏"年龄"。如果你给学生的年龄和教师的年龄一个不同的列名,那么验证就会通过。

Validation fails because the properties Student.Age and Teacher.Age are mapped to the same store-side column "Age." If you gave the student's age and teacher's age a different column name, then validation would pass.

我感兴趣的是你为什么要将Age映射到单独的类而不是把它放在基类中。这是对你的情景的过度简化吗?

I am interested why you are mapping Age to separate classes instead of putting it in the base class though. Is this an oversimplification of your scenario?

David


这篇关于代码优先 - 如何在TPH继承中指定鉴别器列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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