【问题标题】:Entity model relationships?实体模型关系?
【发布时间】:2012-08-24 17:54:26
【问题描述】:

我创建了一个名为 Posts 的表。

POSTS        |
_____________|
post_id      |
parent_id    |  //reference to post_id
post_type_id |  //I have two type
user_id      |  //reference to user table

我从这个表中创建了一个实体模型。我希望是这样的:Model.POSTS 但它是这样显示的 Model.POSTS1Model.POSTS2 这意味着有两个集合。

为什么会这样?是关于 post_type 的吗? POSTS1 = type1POSTS2=type2?

【问题讨论】:

  • 您查看映射了吗? Model.POSTS2 映射到什么?
  • 它们也被映射到帖子。

标签: entity-framework relationship


【解决方案1】:

对不起,他们映射到不同的地方。 Post1 是一个集合 Post2 是一个对象。这意味着如果帖子是孩子,它指的是一位父母。如果 post 是父级,则引用其子级(集合)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 2015-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    相关资源
    最近更新 更多