开发者

Creating an entity for a link table in EF4

I have 3 tables

Table 1

  • Id
  • Name

Table 2

  • Id
  • Name

Link Table

  • Table1Id
  • Table2Id

The link table sets up a many to many relationship between Table 1 and Table 2. I'm using the entity framework which does not automatically create an entity for开发者_Python百科 the Link Table and I need to be able to manage that table directly. Therefore, I need to create an entity for that table.

Here's my question: Am I able to create an entity for the link table as it stands? I know if I add a separate id column to the link table and make that the PK it will create an entity for me, but then I can not set up the association between table 1 and table 2 because the new id property is not mapped. Is there any way around this?


It looks like that you have to review your database schema. I can remember a project (EF2) with association tables which were all represented by EntityCollections. So we were able to add one entity to the collection of the other entity.

Can you give us some more details of the database schema. Perhaps the diagram or something like this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜