Search code examples
fluent-nhibernatehilo

Fluent NHibernate — specify table/column names when using HiLo generator


Yes, nit-picky is a good way to describe this... ;)

Does anyone know if you can specify the table and/or column names to use HiLo using Fluent NHibernate? Currently the schema export creates this...

create table hibernate_unique_key (
     next_hi INTEGER 
)

Solution

  • Figured it out...

    public class IdGenerationConvention : IIdConvention
    {
        public void Apply(IIdentityInstance instance)
        {
            instance.GeneratedBy.HiLo("MyTableName", "NextHighValue", "1000");
        }
    }