[英]2 related entities into 1 table using Entity Framework code first
I have two classes. 我有两节课。 Foo and FooSettings.
Foo和FooSettings。
Foo
- Id
- Name
- Settings
FooSettings
- ShowName
- Discount
And I would like to have a single table in the DB that looks as follows: 我想在数据库中有一个表,如下所示:
Foo
- Id
- Name
- Settings
- SettingDiscount
- SettingShowName
The example is quite simple and probably should collapse Foo and FooSettings into a single object as well. 该示例非常简单,可能还应该将Foo和FooSettings折叠到单个对象中。 Our real scenario has quite a few more fields.
我们的实际场景还有更多领域。 I think what I have done is organized my entities into bounded contexts (correct me if I am wrong)
我认为我所做的是将我的实体组织到有限的上下文中(如果我错了,请纠正我)
I would like to keep those two objects (unless I am completely wrong and there is a better way to do this) but I would like them to map onto a single table in the DB because it is a 1 to 1 relationship. 我想保留这两个对象(除非我完全错了,并且有更好的方法可以这样做),但是我希望它们映射到DB中的单个表,因为它是一对一的关系。
Is it possible to do this using Entity Framework v5.0 code first. 是否可以先使用Entity Framework v5.0代码执行此操作。
尝试按此处所述进行表拆分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.