I have a User model and a Event model in my project. The Event has a creator(User) and has participant(Users) so Event has a one-to-many relationship with User and also a many-t
EF doesn't know where User.Events
has to be mapped to. It could be Event.CreatedBy
or it could be Event.Users
. Both would result in a valid model. You must give EF a little hint what you want by applying the [InverseProperty]
attribute:
public class User
{
...
[InverseProperty("Users")]
public virtual ICollection Events { get; set; }
...
}