title: An association from the table X refers to an unmapped class: System.Guid
body: <p>I have this class:</p>
  
  <pre><code>public class AttachmentLocation
  {
      #region properties
  
      public virtual Guid UserId { get; set; }
  
      public virtual Guid LocationId { get; set; }
  
      public virtual long IndexInLocation { get; set; }
  
      #endregion
  
      #region contained foreign objects
  
      public virtual Attachment Attachment { get; set; }
  
      #endregion
  
  
      #region Methods need to override for CompositeId
  
      public override bool Equals(object obj)
      {
          if (obj == null)
              return false;
          var t = obj as AttachmentLocation;
          if (t == null)
              return false;
          if (UserId == t.UserId &amp;&amp; LocationId == t.LocationId &amp;&amp; Attachment.Id == t.Attachment.Id)
              return true;
          return false;
      }
  
      public override int GetHashCode()
      {
          return (UserId + "|" + LocationId + "|" + Attachment.Id).GetHashCode();
      }
  
      #endregion
  
  }
  </code></pre>
  
  <p>I have this Fluent Mapping:</p>
  
  <pre><code>public class AttachmentLocaionMap : ClassMap&lt;AttachmentLocation&gt;
  {
      public AttachmentLocaionMap()
      {
          Table("Metadata_AttachmentLocation");
          CompositeId()
              .KeyReference(x =&gt; x.UserId, "UserId")
              .KeyReference(x =&gt; x.Attachment.Id, "AttachmentId")
              .KeyReference(x =&gt; x.LocationId, "LocationId");
          Map(x =&gt; x.IndexInLocation).Not.Nullable();
          Map(x =&gt; x.LocationId).Not.Nullable();
  
          HasOne(x =&gt; x.Attachment);
      }
  }
  </code></pre>
  
  <p>which I register:</p>
  
  <pre><code>SessionFactory = Fluently.Configure(configuration).Mappings(m =&gt;
  {
      m.FluentMappings.AddFromAssemblyOf&lt;AttachmentLocaionMap&gt;();           
      m.FluentMappings.AddFromAssemblyOf&lt;FriendDetailsMap&gt;();
  }).BuildSessionFactory();
  </code></pre>
  
  <p>I get this runtime error:</p>
  
  <blockquote>
    <p>An association from the table Metadata_AttachmentLocation refers to an
    unmapped class: System.Guid</p>
    
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code. </p>
    
    <p>Exception Details: NHibernate.MappingException: An association from
    the table Metadata_AttachmentLocation refers to an unmapped class:
    System.Guid</p>
    
    <p>Source Error: </p>
    
    <p>Line 19:  Line 20:  Line 21:             SessionFactory =
    Fluently.Configure(configuration).Mappings(m => Line 22:             {
    Line 23:<br>
    m.FluentMappings.AddFromAssemblyOf();</p>
    
    <p>Source File: C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Infrastructure\Dal\Adapters\NHibernateAdapter\NHibernateHelper.cs
    Line: 21 </p>
    
    <p>Stack Trace: </p>
    
    <p>[MappingException: An association from the table
    Metadata_AttachmentLocation refers to an unmapped class: System.Guid] 
    NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) in
    d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:342<br>
    NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys(Table table,
    ISet done) in
    d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:1169<br>
    NHibernate.Cfg.Configuration.SecondPassCompile() in
    d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:1120<br>
    NHibernate.Cfg.Configuration.BuildSessionFactory() in
    d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:1249<br>
    FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
    d:\Builds\FluentNH-v1.x-nh3\src\FluentNHibernate\Cfg\FluentConfiguration.cs:227</p>
    
    <p>[FluentConfigurationException: An invalid or incomplete configuration
    was used while creating a SessionFactory. Check PotentialReasons
    collection, and InnerException for more detail.</p>
    
    <ul>
    <li>Database was not configured through Database method. ]<br>
    FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
    d:\Builds\FluentNH-v1.x-nh3\src\FluentNHibernate\Cfg\FluentConfiguration.cs:232
    Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateHelper.OpenSession()
    in C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Infrastructure\Dal\Adapters\NHibernateAdapter\NHibernateHelper.cs:21
    Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateHelper.GetSession()
    in C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Infrastructure\Dal\Adapters\NHibernateAdapter\NHibernateHelper.cs:36
    Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateDal<code>1..ctor()
    in C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Infrastructure\Dal\Adapters\NHibernateAdapter\NHibernateDal.cs:16
    Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateDalFactory.GetDal()
    in C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Infrastructure\Dal\Adapters\NHibernateAdapter\NHibernateDalFactory.cs:17
    Ugi.Server.Sources.Logic.SourcesService..ctor() in
    C:\Users\elad\Documents\Visual Studio
    2010\Projects\SVN\UGI\Ugi\Server\Sources\Logic\SourcesService.cs:36<br>
    BuildUp_Ugi.Server.Sources.Logic.SourcesService(IBuilderContext ) +153
    Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext
    context) in
    c:\EntLib\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs:37
    Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext
    context) in
    c:\EntLib\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs:43
    Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
    context) in
    c:\EntLib\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs:110
    Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
    existing, String name, IEnumerable</code>1 resolverOverrides) in
    c:\EntLib\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:512</li>
    </ul>
    
    <p>[ResolutionFailedException: Resolution of the dependency failed, type
    = "Ugi.Common.Model.Sources.ISourcesService", name = "(none)". Exception occurred while: Calling constructor
    Ugi.Server.Sources.Logic.SourcesService(). Exception is:
    FluentConfigurationException - An invalid or incomplete configuration
    was used while creating a SessionFactory. Check PotentialReasons
    collection, and InnerException for more detail.</p>
    
    <ul>
    <li>Database was not configured through Database method.</li>
    </ul>
  </blockquote>
  
  <p>How can I fix that?</p>
  
  <p>TIA</p>