NHibernate Growth Generator - Failed to Get Initial Value

I am trying to use NHibernate (and FluentNHibernate ) on top of an obsolete database. I also use SQLite for tests .

When I try to create a test for mappings using FluentNHibernate PersistenceSpecification , I get the following exception:

NHibernate.Exceptions.GenericADOException: Failed to get initial value for increment generator

I map my id as follows:

Id(f => f.ID, "OID").GeneratedBy.Increment(); 

My test uses SQLite, so when I ran them, the tables were initially empty.

Does anyone have any ideas how to solve this?

Thanks.

+6
sqlite nhibernate fluent-nhibernate
source share
3 answers

You can also try:

 Id(f => f.ID, "OID").GeneratedBy.Native() 

This works for me in SQLite and SQL Server.

+4
source share

Have you tried using GeneratedBy.Identity instead of GeneratedBy.Increment?

0
source share

You can try using seqhilo depending on your database system.

0
source share

All Articles