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?
精彩评论