Skip to content

In EF Core, if a column is an Identity and not the Primary needs metadata added #4

@nick5454

Description

@nick5454

When you have a table column that is an Identity column, but not the Primary key. There needs to be a metadata ignore statement.

builder.Property(x => x.Id)
    .HasColumnName(@"Id")
    .HasColumnType("bigint")
    .IsRequired()
    .ValueGeneratedOnAdd()
    .UseIdentityColumn();
            
builder.Property(x => x.Id)
    .Metadata.SetAfterSaveBehavior(Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Ignore);

The Metadata is needed to avoid saving exceptions, if the column is not in the primary key.

It would be nice to include this in a future release.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions