Fluent nHibernate: Need help with ManyToMany Self-referencing mapping
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!
Remove Inverse() call
精彩评论