title: How can I map not reference object as foreign key on Nhibernate?
body: <pre class="lang-csharp prettyprint-override"><code>public class Entity&lt;TId&gt;
  {
      public virtual TId {get;set;}
  }
  
  public class TenantId
  {
      public virtual Guid Id {get;set;}
  }
  
  public class Tenant
      : Entity&lt;TenantId&gt;
  {
      public string Name {get;set;}
  }
  
  public class AccountId
  {
      public virtual Guid Id {get;set;}   
  }
  
  public class Account
      : Entity&lt;AccountId&gt;
  {
      public Account(TenantId tenantId,AccountId accountId)
      {
          TenantId = tenantId;
          Id= accountId;
      }
  
      public TenantId TenantId {get;set;}
      public string AccountName {get;set;}
  }
  
  public class TenantMap
  {
      public TenantMap()
      {
          Id(x=&gt;x.Id.Id).GeneratedBy.GuidComb();
          Map(x =&gt; x.Name).Not.Nullable();
      }
  }
  
  public class AccountMap
  {
      public AccountMap()
      {
          Id(x=&gt;x.Id.Id).GeneratedBy.GuidComb();
          Map(x=&gt;x.TenantId.Id).Column("TenantId").Not.Nullable(); 
          Map(x =&gt; x.AccountName).Not.Nullable();
      }
  }
  </code></pre>
  
  <p>I need map AccountMap.TenantId as Foreign Key (Tenant). Db must know TenantId is primary key of Tenant. When I add new record to Account like below, nhibernate or db must validate TenantId value exists on Tenants table.</p>
  
  <p>Session.Save(new Account(new TenantId("guid-of-exists-tenant"),new AccountId("guid"))</p>