I'm kind of confuse with the navigation properties in the EF Code First.
The following 2 classes come from ScottGu tutorial on EF Code First.
public class Dinner
{
public int DinnerID { get; set; }
public string Title { get; set; }
public DateTime EventDate { get; set; }
public string Address { get; set; }
public string HostedBy { get; set; }
public virtual ICollection<RSVP> RSVPs { get; set; }
}
public class RSVP
{
public int RsvpID { get; set; }
public int DinnerID { get; set; }
public string AttendeeMail { get; set; }
public virtual Dinner Dinner { get; set; }
}
They are 2 tables In the ScottGu's NerdDinner tutorial: Dinners and RSVP. The column DinnerID is the primary-key for Dinner and a foreign-key for RSVP.
Those are my questions:
- I understand why there's a ICollection RSVPs property in the Diner class, but why a Dinner Dinner property in the RSVP class?
- What's going to happen if I do not add the DINER navigation property in the RSVP class?
I can sum up all my questions by saying: "Isn't there any relationship between Foreign-key in the underline tables and the navigation properties in the model?"
Navigation properties are there to reflect the relationship between tables in the underline database or not?
I'm sorry to be so lengthy, I'm really confused.
Thanks for helping