Setting the initial seed value

16 views
Skip to first unread message

Kim Johansson

unread,
Jun 8, 2011, 8:56:26 AM6/8/11
to nhu...@googlegroups.com
Hello NHibernate users!

I'm trying to set the initial seed value, but nothing I search on gives
the result I want.

I want to set the value on the identity column in my class.

I've tried this mapping:

<id name="Id" unsaved-value="0">
<column name="Id" sql-type="int identity(1,1000000)" />
<generator class="native" />
</id>

and class="identity" and no <generator/> tag at all. Nothing gives the
result I want.
Setting the class to identity or native gives exception about duplicate
"identity" and no generator tag gives exception that you can't set the
identity value on insert.

This is with a generated database with the SchemaExport class.

I can fix the database manually, but I'd like the feature where
NHibernate generates the database-schema for me.

// Kim Johansson, A happy NHibernate user

Tomek Pluskiewicz

unread,
Jun 9, 2011, 3:36:36 AM6/9/11
to nhu...@googlegroups.com
Hi!

I don't know why what your are trying  fails. But as an alternative solution your could add the manual database fix to the database-object tag. Refer to this post: http://ayende.com/blog/3947/nhibernate-mapping-database-object

It may not be the best option out there, but you won't lose the benefit of SchemaExport...

Regards
Tomasz
Reply all
Reply to author
Forward
0 new messages