R – Override default Fluent NHibernate Column Mapping

fluent-nhibernate

I am trying to find the syntax for changing the automap behavior of Fluent NHibernate.

How would I modify the code below to map the UserId property to a column named UserIdentifier (as an example)?

public class MyTypeMap : ClassMap<MyType>
{
    public MyTypeMap()
    {
            Table("MyTypes");
            Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty);
            Map(x=> x.UserId);
    }
}

Thanks

Best Answer

public class MyTypeMap : ClassMap<MyType>
{
    public MyTypeMap()
    {
            Table("MyTypes");
            Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty);
            Map(x=> x.UserId).Column("UserIdentifier");
    }
}
Related Topic