public async Task <int> GetNext(IdSequence sequence) { await using var command = _context.Database .GetDbConnection() .CreateCommand(); command.CommandText = $"select nextval('{sequence.Name}')"; command.CommandType = CommandType.Text; _context.Database.OpenConnection(); var result = await command.ExecuteScalarAsync(); return(int.Parse(result.ToString(), CultureInfo.InvariantCulture)); }
public static void ApplySequenceConfiguration(this ModelBuilder modelBuilder, IdSequence sequence) { modelBuilder.HasSequence <int>(sequence.Name) .StartsAt(1) .IncrementsBy(1); }