Override default Fluent NHibernate Column Mapping

2019-07-17 21:34发布

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

2条回答
贪生不怕死
2楼-- · 2019-07-17 21:58
public class MyTypeMap : ClassMap<MyType>
{
   public MyTypeMap()
   {
        Id (x => x.InstanceId).Column ("UserIdentifier").GeneratedBy.Guid().UnsavedValue(Guid.Empty);
   }
}
查看更多
Evening l夕情丶
3楼-- · 2019-07-17 22:01
public class MyTypeMap : ClassMap<MyType>
{
    public MyTypeMap()
    {
            Table("MyTypes");
            Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty);
            Map(x=> x.UserId).Column("UserIdentifier");
    }
}
查看更多
登录 后发表回答