I am trying to match many-to-many relationships with the same object. The User object has an IList<User> data field for Contacts , in which data about users' contacts / friends is stored:
public class User : DomainModel { public virtual IList<User> Contacts { get; protected set; }
When I try to use the free API to map many relationships, this causes some problems. Apparently, when I use HasMany() in the user.Contacts property, it does not have a WithMany() method to call the following. Intellisense from Visual Studio only shows WithOne() , but not WithMany() .
modelBuilder.Entity<User>().HasMany(u => u.Contacts).WithMany() // gives compile time error: CS1061 'CollectionNavigationBuilder<User, User>' does not contain a definition for 'WithMany' and no extension method 'WithMany' accepting a first argument of type
So why is this happening? Is there something I did wrong to match this many-to-many relationship?
Lord yggdrasill
source share