This project has moved and is read-only. For the latest updates, please go here.
NHilo is an implementation of the Hilo algorithm (from Hibernate). It aims to be a tool for generating database keys without having to rely on DBMS features like SQL Server's identity column or Oracle's sequence. The repository shouldn't be responsible for generating any information, it must be only a storage. Primary keys, even surrogate keys, must be defined in the application tier.

This component can be downloaded using Nuget add-in in Visual Studio. For more information, please visit

Here's a snippet showing how to use NHiLo. First, you need to create a factory that will create a sequence generator object for each entity you have. Then you simply call the GetKey method and it give you a brand new and unique value for use as a primary key.

using NHilo;
// ...
var factory = new HiLoGeneratorFactory();
var generator = factory.GetKeyGenerator("myEntity");
long key = generator.GetKey();

In your application configuration file (web.config, for example), you need specified at least one connection string. NHiLo will use the last connection string for storing its control value table. Currently we have tested NHiLo with SQL Server, SQL Server CE, MySQL and Oracle.

Version 1.3.0 introduced GuidGeneratorFactory class. Now you can generate sequential guids as keys.

Go further on the Documentation.

Obs. This is not a replacement for NHibernate (that's a great library, it's stable and works very well). Use NHilo when you can't (for any reason) use NHibernate.

Last edited Dec 8, 2015 at 11:51 PM by fabiogouw, version 7