Reputation: 2120
We have a table mapped in Fluent NHibernate with an Id generated by a Hilo sequence.
this.Id(x => x.Id).GeneratedBy.SeqHiLo("seq_hp", "1000");
We now need to specify a Default value on the Id (set to the next sequence value) to make it work with a SQL Merge statement.
However, NHibernate will generate the sequence only after the tables are generated, so the next statement will fail because there is not (yet) a sequence.
this.Id(x => x.Id).GeneratedBy.SeqHiLo("seq_hp", "1000")
.Default("next value for seq_hp");
Is there any way in NHibernate to specify the creation of the sequence before the creation of the table? We are using Fluent mapping, but NHibernate's code or XML mapping solutions are welcome.
Upvotes: 3
Views: 895
Reputation: 30813
The other way around is also feasable. Implement IAuxiliaryDatabaseObject
to add the Default for the column using Sql. There is the base class AbstractAuxiliaryDatabaseObject
which does provide a default implementation.
Upvotes: 1