A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
@Cenk , Welcome to Microsoft Q&A,
You could try the following code to generate autoincrement fields in ef core 6.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Order>()
.Property(e => e.OrderNumber)
.ValueGeneratedOnAdd().UseIdentityColumn(1, 1);
}
The above code means that OrderNumber column will start from 1 and increase by 1.
Hope this could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.