title: FluentNhibernate and HasMany
body: <p>I try a simple Test Application with FluentNhibernate but it doesnt work as I expected.
  Here are my classes:</p>
  
  <pre><code>public class Document : DataEntity
  {
      public virtual string Title { get; set; }
  
      public virtual string FileName { get; set; }
  
      public virtual DateTime LastModificationDate { get; set; }
  
      public virtual User LastModificationBy { get; set; }
  
      public virtual byte[] Content { get; set; }
  
      public virtual User Owner { get; set; }
  }
  
  public class User : DataEntity
  {
      public virtual string FirstName { get; set; }
  
      public virtual string LastName { get; set; }
  
      public virtual string Login { get; set; }
  
      public virtual string PasswordHash { get; set; }
  
      public virtual string Email { get; set; }
  
      public virtual IList&lt;Document&gt; OwnedDocuments { get; set; }
  
      public User()
      {
          this.OwnedDocuments = new List&lt;Document&gt;();
      }
  }
  
  internal class UserMapping : ClassMap&lt;User&gt;
  {
      public UserMapping()
      {
          this.Id(x =&gt; x.Id);
          this.Map(x =&gt; x.FirstName);
          this.Map(x =&gt; x.LastName);
          this.HasMany(x =&gt; x.OwnedDocuments).Inverse();
      }
  }
  
      public DocumentMapping()
      {
          this.Id(x =&gt; x.Id);
          this.Map(x =&gt; x.Title);
          this.Map(x =&gt; x.FileName).Not.Nullable();
          this.Map(x =&gt; x.LastModificationDate).Index("IDX_ModificationDate");
          this.Map(x =&gt; x.Content);
          this.References(x =&gt; x.LastModificationBy).Column("LastModificationBy");
          this.References(x =&gt; x.Owner).Column("Owner");
          this.Table("Document");
      }
  </code></pre>
  
  <p>I try to test it with the following code</p>
  
  <pre><code>using (var transaction = Session.BeginTransaction())
          {
              var users = this.kernel.Get&lt;IRepository&lt;User&gt;&gt;();
              var document = this.kernel.Get&lt;IRepository&lt;Document&gt;&gt;();
              var user = new User { Login = "Blubb" };
              users.Add(user);
              var list = Builder&lt;Document&gt;.CreateListOfSize(50).All().With(x =&gt; x.Owner = user).Build().ToList();
              var list2 = Builder&lt;Document&gt;.CreateListOfSize(50).All().Build().ToList();
              list.ForEach(x =&gt; user.OwnedDocuments.Add(x));
              document.Add(list);
              document.Add(list2);
              transaction.Commit();
              var i = document.All().Count();
              i.Should().Be(50);
              var docs = ((IGuidKeyedRepository&lt;User&gt;)users).FindBy(user.Id).OwnedDocuments.Count();
              docs.Should().Be(50);
          }
  </code></pre>
  
  <p>The first problem is, why is the document count always 0 when I dont call document.Add(list);? I thought when I add some documents to the document collection of the user, they will be automaticly added to the documents?
  And why ist the last test 100? Because I filter on the documents belongs to that user.</p>