efcore
efcore copied to clipboard
No IDENTITY for primary key in SQL server
I've created simple SQL Server db with entity:
class Item
{
public int Id { get; set; }
}
generated script:
CREATE TABLE [dbo].[Item] (
[Id] INT NOT NULL,
CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED ([Id] ASC)
);
Isn't there should be IDENTITY token?
EF 7.0.0-bata8-15162 build
Hmm, it seems to be working on 7.0.0-beta8-15534 for me.
This entity type...
class Item
{
public int Id { get; set; }
}
...results in this migration...
migrationBuilder.CreateTable(
name: "Item",
columns: table => new
{
Id = table.Column<int>(isNullable: false)
.Annotation(
"SqlServer:ValueGenerationStrategy",
SqlServerIdentityStrategy.IdentityColumn),
},
constraints: table =>
{
table.PrimaryKey("PK_Item", x => x.Id);
});
...which produces this SQL.
CREATE TABLE [Item] (
[Id] int NOT NULL IDENTITY,
CONSTRAINT [PK_Item] PRIMARY KEY ([Id])
);
Could you share your DbContext code?
I can't reproduce the issue now. I'm sorry!