I'm having difficulty with the many to many hierarchy not updating correctly after a save. I have a simple unit test that reproduces the problem.
The relationship is AppUser -> AppUserRoleAssn -> Role, with the primary key of Role and AppUser migrated to the assn. I'm freshly creating the user in a setup fixture, and deleting in a teardown, so it should be clean. I also verified it is getting added to the database, and if I set UpToRoleCollection = null and save the user, the test passes, as that seems to force a refresh.
Please let me know if you have any ideas as to what I'm doing wrong. Or maybe I found a bug. :)
Code:
Assert.That(u.UpToRoleCollection.Count, Is.EqualTo(0));
Role r = new Role();
r.LoadByName("admin");
Assert.That(r.RoleName,Is.EqualTo("admin"));
u.AssociateRoleCollection(r);
u.Save();
Assert.That(u.UpToRoleCollection.Count, Is.EqualTo(1)); // Count is still ZERO here, assert fails