title: NHibernate map collection without foreign key?
body: <p>I've not been able to find an answer to this question.</p>
  
  <p>Say you have <code>ClassA</code>:</p>
  
  <pre><code>public class ClassA {
      public Guid Id { get; set; }
      public IList&lt;ClassB&gt; { get; set; }
  }
  </code></pre>
  
  <p>And <code>ClassA</code> has nested a collection of <code>ClassB</code> objects:</p>
  
  <pre><code>public class ClassB {
      public Guid Id { get; set; }
      public string SomeProperty { get; set;}  
  }   
  </code></pre>
  
  <p>Is there any way using NHibernate to map these objects to tables, generate the schemas but NOT have a foreign key relationship created for the <code>ClassB</code> table?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Figured the solution - when mapping by code:</p>
  
  <pre><code>Bag&lt;ClassA&gt;(x =&gt; x.ClassB, 
              collectionMapping =&gt; {
                  collectionMapping.Table("ClassB");
                  collectionMapping.Cascade(Cascade.All);
                  collectionMapping.Key(key =&gt; { 
                        key.Column("ClassAId");
                        key.ForeignKey("none");
                   });
                  collectionMapping.Lazy(CollectionLazy.NoLazy);
             },
             mapping =&gt; mapping.OneToMany(x =&gt; {
                   x.Class(typeof(ClassB));
             })
        );
  </code></pre>