broccoli_soup
broccoli_soup

Reputation: 309

How to have SQL Server generate a sequential primary key?

When adding a new Entity Framework object to a database, how could one have SQL Server generate a sequential primary key for that object?

Edit:

Apparently by creating the table using a query which defines the primary key as IDENTITY (1, 1):

CREATE TABLE TableName(ID int PRIMARY KEY IDENTITY (1, 1), [other columns])

Upvotes: 2

Views: 2874

Answers (1)

broccoli_soup
broccoli_soup

Reputation: 309

By creating the table using a query which defines the primary key as IDENTITY (1, 1):

CREATE TABLE TableName(ID int PRIMARY KEY IDENTITY (1, 1), [other columns])

Upvotes: 3

Related Questions