NHibernate Naming Conventions - Eliminating Keyword Conflicts
2 answers
I had a similar problem. The fix is ββto use the FluentNHibernate Column property to place parentheses around the column name for the key property.
Here is the entity with the problematic Key property:
public class MyEntity
{
public virtual int Id { get; set; }
public virtual string Key { get; set; }
}
Here's how to specify the column name in the mapping:
public class MyEntityMap : ClassMap<MyEntity>
{
public MyEntityMap()
{
Id(x => x.Id).GeneratedBy.Assigned();
// Note the brackets around Key
Map(x => x.Key).Column("[Key]").Not.Nullable();
}
}
+1
source to share