How to delete an entry in the connection table in Entity Framework 5?
When reverse engineering my DataContext, the Entity Framework seemed to recognize my join table and automatically add collections to my models to represent the M: M relationship. This is great when adding elements, as I can just build my entire Entity and everything will work out right. Perfect.
However, I do not understand how to withdraw a relationship. For example, an Activity may have several contacts associated with it, and this is due to the use of the connection table (dbo.ActivityContacts), which consists of columns:
Both my Activity and Contact models were updated by EF using Collections to represent another. For example, my Activity model is as follows:
public class Activity { public int ActivityID { get; set; } public string Subject { get; set; } public virtual ICollection<Contacts> Contacts { get; set; } }
In a non-EF environment, I just delete the entry from the connection table and move on with my day. However, it seems that I cannot access the navigation table directly using EF, so I got a little confused about how to delete the record (relationships).
How to delete an entry from the connection table in the Entity Framework?
source share