concept sequence in category entity framework

appears as: sequence, sequence, Sequences
Entity Framework Core in Action

This is an excerpt from Manning's book Entity Framework Core in Action.

The last part of the command reveals something about LINQ. Until a final execute command is applied at the end of the sequence of LINQ commands, the LINQ is held as a series of commands; it hasn’t been executed on the data yet. EF Core can translate each command in the LINQ query into the correct commands to use for the database you’re using. In EF Core, a query is executed against the database when

A sequence or flow is often shown to a human user as a sequence of pages or steps in a wizard, but backed up by the data manipulations that each stage needs done by some sort of CRUD and/or business logic.

Listing 8.9 The DbContext with the Fluent API configuration and the Order class
class MyContext : DbContext
{
    public DbSet<Order> Orders { get; set; }

    protected override void OnModelCreating
       (ModelBuilder modelBuilder)
    {
        modelBuilder.HasSequence<int>(    #1  
                "OrderNumbers", "shared")    #1  
            .StartsAt(1000)    #2  
            .IncrementsBy(5);    #2  

        modelBuilder.Entity<Order>()
            .Property(o => o.OrderNo)
            .HasDefaultValueSql(
                "NEXT VALUE FOR shared.OrderNumbers");    #3  
    }
}

public class Order
{
    public int OrderId { get; set; }
    public int OrderNo { get; set; }
}

#1   Creates a sequence OrderNumber in the schema “shared”. If no schema is provided, it’ll use the default schema.
#2   These are optional, and allow you to control the sequence start and increment. The default is start at 1 and increment by 1.
#3   A column can access the sequence number via a default constraint. Each time the NEXT VALUE command is called, the sequence is incremented. The SQL shown is for an SQL Server database and will be different for other database providers.