Ok, I\'m trying to figure out how to setup my DB properly.
I have two classes:
public class Event
{
public int EventId { get; set; }
public stri
You should just need an ICollection
property on each class:
public class Event
{
public int EventId { get; set; }
public string EventName { get; set; }
public virtual ICollection Dogs { get; set; }
}
public class Dog
{
public int DogId { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public virtual ICollection Events { get; set; }
}
EF should be able to handle a many-to-many relationship without you explicitly defining the mapping, but if you want to set up the junction table yourself, you can do that by overriding the OnModelCreating
method (as explained in other answers).