title: Fluent NHibernate: How to create one-to-many bidirectional mapping?
body: <p><strong>Basic question</strong>: How to I create a bidirectional one-to-many map in Fluent NHibernate?</p>
  
  <p><strong>Details:</strong></p>
  
  <p>I have a parent object with many children.  In my case, it is meaningless for the child to not have a parent, so in the database, I would like the foreign key to the parent to have NOT NULL constraint.  I am auto-generating my database from the Fluent NHibernate mapping.</p>
  
  <p>I have a parent with many child objects like so:</p>
  
  <pre><code>public class Summary
  {
     public int id {get; protected set;}
  
     public IList&lt;Detail&gt; Details {get; protected set;}
  }
  
  public  class Detail
  {
     public int id {get; protected set;}
  
     public string ItemName {get; set;}
  
    /* public Summary Owner {get; protected set;} */ //I think this might be needed for bidirectional mapping?
  }
  </code></pre>
  
  <p>Here is the mapping I started with:</p>
  
  <pre><code>public class SummaryMap : ClassMap&lt;Summary&gt;
  {
      public SummaryMap()
      {
          Id(x =&gt; x.ID);
  
          HasMany&lt;Detail&gt;(x =&gt; x.Details);
      }
  }
  
  public class DetailMap : ClassMap&lt;Detail&gt;
  {
      public DetailMap()
      {
          Id(x =&gt; x.ID);
  
          Map(x =&gt; x.ItemName).CanNotBeNull();
      }
  }
  </code></pre>
  
  <p>In the Detail table, the Summary_id should be Not Null, because in my
  case it is meaningless to have a Detail object not attached to the
  summary object.  However, just using the HasMany() map leaves the Summary_id foreign key nullable.</p>
  
  <p>I found in the NHibernate docs (<a href="http://www.hibernate.org/hib_docs/nhibernate/html/collections.html" rel="noreferrer">http://www.hibernate.org/hib_docs/nhibernate/html/collections.html</a>) that "If the parent is required, use a bidirectional one-to-many association".</p>
  
  <p>So how do I create the bidirectional one-to-many map in Fluent NHibernate?</p>