如何将单个模型类映射到Code First CTP5中的两个表? [英] How do I map a single model class to two tables in Code First CTP5?

查看:64
本文介绍了如何将单个模型类映射到Code First CTP5中的两个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张包含患者信息的表格,我添加了一个新表格,为患者信息添加了几个可选值。在这种情况下,它需要是两个表,因为我无法编辑第一个表的模式。


如何创建映射到这两个表的单个模型类? 这似乎微不足道,但我在搜索中找不到解决方案。  


Chris

解决方案

我通过设置两个模型类来解决这个问题使用两者之间的一对一关系。它有效,但它使我的模型更加丑陋。希望我忽略了一些东西。


有没有办法让一个模型类映射到两个表?


Chris


I have a table with patient information and I've added a new table that adds a couple of optional values for the patient information. In this case it needs to be two tables since I can't edit the schema of the first one.

How do I make a single model class that maps to those two tables? It seems trivial, but I'm not finding a solution in my searches.  

Chris

解决方案

I've hacked around this by setting two model classes and using a one to one relationship between the two. It works, but it makes my model uglier. Hopefully I've overlooked something.

Is there a way to have a single model class that maps to two tables?

Chris


这篇关于如何将单个模型类映射到Code First CTP5中的两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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