I’m doing something to migrate data (the MySQL migration tool crashes…long story…anyway) so I’m just using the ServiceStack models and ORMLite to read from one database and write to the other.
But inserting an object with an autoincrement non-zero Id value is being ignored, and instead creates a row with a new auto increment value. It seems AutoIncrement attribute always forces that column to be ignored from the INSERT statement.
public class Thing
{
[AutoIncrement]
[PrimaryKey]
public int Id {get; set;}
}
:
// creates a new row with Id = 1 (the next autoincrement value)
Db.Insert<Thing>(new Thing());
// creates a new row of Id = 2 not 100
Db.Insert<Thing>(new Thing { Id = 100 });
This looks to be by design and I can’t see a simple way to override the behaviour. Do you have any suggestions, other than overriding the Id columns of each model definition?
Is it something can can be enhanced?