title: Nhibernate: Trouble mapping a one-to-many relationship
body: <p>I'm very, very new to nhibernate, and I'm certain there are a lot of obvious things I'm overlooking here, but I've been searching for the answer for a few days now and simply cannot find a solution which fits my specific problem. I would really, really appreciate your help. </p>
  
  <p>I'll describe my problem first, and then post the code:</p>
  
  <p>In my object model, I have an "Event" with an IList of "Organizer". I want to use nhibernate so that when I do "session.Save(anEvent)", data is written to three tables in the database: Events, Organizers, and Organizers_Events (the join table). When I use the below code, I get the following error: </p>
  
  <pre><code>Invalid column name 'EventID'
  </code></pre>
  
  <p>My code:
  First, the .hbm files:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     assembly="BLL"
                     namespace="BusinessLogic"&gt;
  
    &lt;class name="Event" table="Events"&gt;
      &lt;id name="EventID"&gt;
        &lt;column name="ID"/&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="Name"&gt;
        &lt;column name="Name"/&gt;
      &lt;/property&gt;
      &lt;bag name="Organizers" table="Organizers_Events" inverse="false" cascade="all-delete-orphan" lazy="true" access="nosetter.camelcase-underscore" &gt;
        &lt;key column="EventID"/&gt;
        &lt;one-to-many class="Organizer" /&gt;
      &lt;/bag&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  
  &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     assembly="BLL"
                     namespace="BusinessLogic"&gt;
  
    &lt;class name="Organizer" table="Organizers"&gt;
      &lt;id name="Id"&gt;
        &lt;column name="ID"/&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="FullName"&gt;
        &lt;column name="FullName"/&gt;
      &lt;/property&gt;
      &lt;many-to-one name="TheEvent" column="EventID" /&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Next, the objects:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  /// &lt;summary&gt;
  /// Summary description for Event
  /// &lt;/summary&gt;
  /// 
  
  namespace BusinessLogic
  {
      public class Event
      {
          private int eventID;
  
          public virtual int EventID
          {
              get { return eventID; }
              set { eventID = value; }
          }
          private IList&lt;Organizer&gt; _organizers = null;
  
          public virtual IList&lt;Organizer&gt; Organizers
          {
              get { return _organizers; }
              set { _organizers = value; }
          }
          public Event()
          {
              //
              // TODO: Add constructor logic here
              //
          }
      }
  }
  
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace BusinessLogic
  {
      public class Organizer:Invitee
      {
          private Event theEvent = new Event();
  
          public virtual Event TheEvent
          {
              get { return theEvent; }
              set { theEvent = value; }
          }
      }
  }
  </code></pre>
  
  <p>And finally, the database schema:</p>
  
  <pre><code>CREATE TABLE [dbo].[Events](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [Name] [nvarchar](max) NOT NULL
  ) ON [PRIMARY]
  
  CREATE TABLE [dbo].[Organizers](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [FullName] [nvarchar](550) NULL
  ) ON [PRIMARY]
  
  CREATE TABLE [dbo].[Organizers_Events](
      [OrganizerID] [int] NOT NULL,
      [EventID] [int] NOT NULL
  ) ON [PRIMARY]
  </code></pre>
  
  <p>I've cut out the irrelevant data to simplify the issue. I don't think any of the other stuff has any affect on my problem here. For our purposes here, I just want the Event object to write it's EventID and Name to the Events table, each organizer object in the IList to write its ID and FullName to the Organizers table, and the EventID and the Organizer's ID to be written to the Organizers_Events table.</p>
  
  <p>What am I doing wrong?  If it's a lot, please tell me. Or if there's an answer already online that I've missed please direct me to it.</p>