diff --git a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs index 3067680755..97ef11d031 100644 --- a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs +++ b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs @@ -539,7 +539,10 @@ void GetSequences() Debug.Assert(sequence.MinValue.HasValue); defaultStart = sequence.MinValue.Value; } else { - defaultMin = long.MinValue + 1; + // PostgreSQL 10 changed the default minvalue for a descending sequence, see #264 + defaultMin = _connection.PostgreSqlVersion >= new Version(10,0) + ? long.MinValue + : long.MinValue + 1; defaultMax = -1; Debug.Assert(sequence.MaxValue.HasValue); defaultStart = sequence.MaxValue.Value;