DTul
DTul

Reputation: 679

How to set auto-increment to value other than one in EF Core Fluent API

I'm using the Fluent API to define my db entity. Now I need to set the increment for my identity to a value that is not one.

I would like to have the SQL equivalent of my_id int IDENTITY(1,2).

The following code always generates an IDENTITY(1,1)

builder.HasKey(m => m.MyId);
builder.Property(m => m.MyId).ValueGeneratedOnAdd();

Upvotes: 0

Views: 111

Answers (1)

DTul
DTul

Reputation: 679

builder.Property(m => m.MyId).UseIdentityColumn(1, 10);

Upvotes: 1

Related Questions