I\'m struggling to get my head round how the HiLo generator works in NHibernate. I\'ve read the explanation here which made things a little clearer.
My understanding
Looking at the keys generated by my Nhibernate 3 HiLo objects, the algorithm looks like: (Hi * Lo) + Hi
So with my Hivalue in the DB as 390 and with my configuration as follows:
TableId = 1
HiValue
NextValue
10
I restart my app pool and get (390 * 10) + 390 = 4290, the range being 4290 - 4300.
This is the reason why you get seemingly strange gaps in your primary keys because the next generated key from a hi value of 391 is 4301, and the range is 4301 - 4311.