Many to Many relationship using SQL and Linq (entity framework/to entities)

余生颓废 提交于 2019-12-10 10:23:47

问题


I have two tables:

- Attendees
- Events

Normally, I would create a mapping table 'EventAttendeeMap' to link these tables into a many to many relationship.

Is this the best way of doing so? Should I store the list of AttendeeIds in an xml column instead on the Events table?

I am using .NET 3.5/4 with Linq as the DAL (although I think this is irrelevant to the design question being asked, possibly).

Interested to see what people's opinions are.

Thanks. Dave


回答1:


A mapping table is definitely the best way to do it - the Entity Framework will convert the mapping table into a collection of entities on both sides and the table itself will essentially disappear.




回答2:


In short yes - create a mapping table to hold the event id and the attendee id.

There is a good question here that might be of interest to you.



来源:https://stackoverflow.com/questions/3530034/many-to-many-relationship-using-sql-and-linq-entity-framework-to-entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!