I keep getting the exception Association references unmapped class: System.Guid
with NHibernate 3.1 and FluentNHibernate 1.2.
I'm not sure how this is possible. Isn't the mapping of Guid handled internally?
I saw several previous mentions of a bug in Fluent NHibernate 1.0 and someone mentioned to use trunk instead where it was fixed, but I'm on 1.2 rather than 1.0, so presumably this issue has been resolved.
Edit: Here's some additional information -- an example HBM I've exported from the Fluent AutoMapper looks like the following
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class xmlns="urn:nhibernate-mapping-2.2" lazy="false" name="Treadmarks.Bus.Frontend.Model.PassType, Frontend, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`PassType`">
<id name="PassTypeId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="PassTypeId" />
<generator class="guid.comb" />
</id>
<property name="Name" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Name" />
</property>
<property name="UsageInterval" type="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="UsageInterval" />
</property>
</class>
</hibernate-mapping>
And following is the FNH code that generates said HBM:
private class AutomappingConfiguration : DefaultAutomappingConfiguration
{
public override bool ShouldMap(Type type)
{
return type.Namespace.StartsWith("Treadmarks.Bus.Frontend.Model");
}
public override bool IsId(FluentNHibernate.Member member)
{
return member.Name == member.DeclaringType.Name + "Id";
}
}
public static Configuration BuildConfiguration()
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.ConnectionString("Data Source=Treadmarks.db; Compress=true"))
.Mappings(
m => m.AutoMappings.Add(AutoMap.Assembly(Assembly.GetExecutingAssembly(), new AutomappingConfiguration())
.Conventions.Add(
DefaultLazy.Never(),
LazyLoad.Never())
).ExportTo("mappings.hbm"))
.BuildConfiguration();
}
It turns out FNH can't properly generate mapping for List<Guid>
like it can for List<int>
, etc. I'll report this to the FNH team.