I'm using SQLite in my unit tests and SQL Server 2008 as production
database. I have a requirement to genereate unique integer type of id
and I'm using the IDENTITY feature to do so:

this.Map(x =>
x.BatchId).Access.CamelCaseField().Not.Nullable().Generated.Always().CustomSqlType("int
IDENTITY(1,1)").Not.Insert().Not.Update()

It works just as expected with SQL Server but the problem is SQLite
which I'm using in unit tests. With that mapping the following column
is generated:

BatchId int IDENTITY(1,1) not null

When I try to insert new batch I get the following error:

Abort due to constraint violation. Batch.BatchId may not be NULL

Just for the sake of unit tests I also tried following mapping:
this.Map(x =>
x.BatchId).Access.CamelCaseField().Not.Nullable().Generated.Always().CustomSqlType("INTEGER
AUTOINCREMENT").Not.Insert().Not.Update();

That will generate following column definition but fail at
initialization because there are two primary keys (I'm using guid as
primary key for all the entities):
INTEGER PRIMARY KEY AUTOINCREMENT

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to