forked from sharparchitecture/Sharp-Architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
HiLoGenerator
geoffreysmith edited this page Jul 5, 2011
·
2 revisions
In your Infrastructure project, under NHibernateMaps\Conventions:
public class PrimaryKeyConvention : IIdConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IIdentityInstance instance)
{
instance.Column(instance.EntityType.Name + "Id");
instance.UnsavedValue("0");
instance.GeneratedBy.HiLo("1000");
}
}
Create the following table:
CREATE TABLE [dbo].[hibernate_unique_key](
[next_hi] [int] NOT NULL
) ON [PRIMARY]
Populate the column with a number to seed and you're done.