By default the behaviour of FNH is to map enums to its string in the db.
But while mapping an enum as part of a composite key, the property gets mapped as int.
e.g.
in this case
public class Address : Entity
{
public Address() { }
public virtual AddressType Type { get; set; }
public virtual User User { get; set; }
Where AddresType is of
public enum AddressType
{
PRESENT, COMPANY, PERMANENT
}
The FNH mapping is as
mapping.CompositeId().KeyReference(x => x.User, "user_id").KeyProperty(x => x.Type);
the schema creation of this mapping results in
create table address (
Type INTEGER not null,
user_id VARCHAR(25) not null,
and the hbm as
<composite-id mapped="true" unsaved-value="undefined">
<key-property name="Type" type="Company.Core.AddressType, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Type" />
</key-property>
<key-many-to-one name="User" class="Company.Core.CompanyUser, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="user_id" />
</key-many-to-one>
</composite-id>
Where the AddressType should have be generated as
type="FluentNHibernate.Mapping.GenericEnumMapper`1[[Company.Core.AddressType,
How do I instruct FNH to mappit as the default string enum generic mapper?