Data Annotation to start with specific ID in ServiceStack

I have a simple Id in my model like this:

   public Int32 Id { get; set; }

It auto-increments whenever a new record is inserted, but it always begins with 0. What if I wanted to make it begin with 10000? I would like to set a default starting ID. Any way to do this through data annotations?

1 answer

  • answered 2018-03-11 13:27 mythz

    No this is not available via an attribute, each RDBMS has their own syntax for resetting the AutoIncrement, e.g. for SQL Server:

    db.ExecuteSql("DBCC CHECKIDENT (MyTable, RESEED, 10000)");