2

I have an entity called User which can have a list of other Users called Friends (kinda like Facebook).

In my User entity, I've delcared a public virtual IList Friends { get; private set;} property, and an creating the list in the constructor. I also have an "AddFriends" method that adds Users to the Friends list.

In my UserMapping class I have the following code to map the relationship

HasManyToMany(x => x.Friends) 
                .ParentKeyColumn("UserId")
                .ChildKeyColumn("FriendId")
                .Table("UserFriends")
                .Inverse().Cascade.SaveUpdate().Not.LazyLoad();

All the tables get created correctly but nothing ever gets put in the UserFriends table and every user that comes back has an empty Friends list.

Any advice?

Thanks!

James Bender
  • 1,175
  • 1
  • 11
  • 22

1 Answers1

2

Remove Inverse() call

maciejkow
  • 6,403
  • 1
  • 27
  • 26