I’m new to OrmLite and I am hopeful that there is some DB Independent magic to solve the age old sequence number vs auto-increment problem.
In a nutshell, we don’t want to use auto-increment fields, for some important fields due to problems that can occur during replication and backup/restore.
But since we’re not sure where were going to land, (MYSQL or SQLServer) and each database sort of has DB specific ways to solve this, i was hopeful that a library or technique can be shared.
I wish i had the cash to buy oracle db’s where the SEQUENCE operator existed.
OrmLite has RDBMS-agnostic support for [AutoIncrement] where it will use the appropriate RDBMS construct for each provider, it doesn’t have support for an alternative version of Auto Increment based on custom sequences. You could potentially build your own support by using OrmLite’s Pre / Post Custom SQL Hooks to create a custom trigger that does this, we use a similar feature in to implement RowVersion support for MySql.
var modelDef = typeof(T).GetModelMetadata();
modelDef.PrimaryKey.AutoIncrement = false;
//... Id's are included in Inserts
modelDef.PrimaryKey.AutoIncrement = true;