0

Is it possible to specify the sequence start value when using identity columns ?

Combine this

        modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
            .StartsAt(1000);

with this

modelBuilder.ForNpgsqlUseIdentityColumns();

in code.

Avin Kavish
  • 8,317
  • 1
  • 21
  • 36
  • No, identity and sequence objects have different behavior. – H. Herzl May 20 '19 at 04:38
  • True, though it is possible to specify the start value of an identity. Perhaps there's a code first syntax for it? – Avin Kavish May 20 '19 at 05:32
  • No, As I know there is no way to set the seed or increment value for identity with code first, You need to execute raw SQL for that: https://stackoverflow.com/questions/5974554/ef-code-first-how-to-set-identity-seed – H. Herzl May 20 '19 at 15:50

1 Answers1

0

This is supported by PostgreSQL but hasn't yet been implemented in the Npgsql EF Core provider. It is being tracked by https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/819 (upvote if you're interested).

Shay Rojansky
  • 15,357
  • 2
  • 40
  • 69