views:

105

answers:

2

I'm trying out the Model First approach introduced in Entity Framework with VS2010/.Net 4.0, and now I don't really know how to do this. I start out with the following Entities:

Contact                           Event
*******                           *****
Id (Int32, not null, pk)          Id (Int32, not null, pk)
Name (Name, not null)             Name (String, not null)
Address (Address, not null)       Duration (Duration, not null)
Email (String)
Phone (String)

where Name, Address, and Duration are complex types that I defined.

Now, I want to add an RSVP Entity, which works as a many-to-many mapping from Contacts to Events, but also holds some extra information in a complex type I called Payment. The table would probably look something like this:

RSVP
****
ContactId (int, not null, pk)
EventId (int, not null, pk)
Payment_Date (datetime, not null)
Payment_Amount (double, not null)

When try to construct this entity in the Model Designer, I want to add the ContactId and EventId fields by adding many-to-many relationships to the respective tables, but when I do so I can't select the two fields to be the primary key of the table (or the Entity Key of the entity).

How do I do this?

A: 

Actually, I think that you don't have to create a separate entity for RSVP, just a Many to Many relationship between the two entities.

Let me know if that helps..

hminaya
A: 

I think it becomes more complicated than a simple many-to-many relationship between the two entities when you add the additional data points to the link table. Once the linking possesses its own data, it can no longer be abstracted away to a mere navigation property.

kdawg
Not what I wanted to hear, but I ended up navigating *via* RSVP's both ways.
Tomas Lycken