Skip to content

ModelValidator: Do not warn for explicitly configured shadow keys #7238

@andresmoschini

Description

@andresmoschini

I have migrated from RC2 and now I am having this warning when I generate migrations:

The key {'Id'} on entity type 'ExtraDeliveryCostByVolume' contains properties in shadow state - {'Id'}. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings API (event id 'CoreEventId.ModelValidationWarning'). ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.

I understand that Id property is shadow, it is true, but, why is it a warning? is there any problem on having a shadow property as primary key?

The model is configured in the follow way:

  protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
    . . .
    modelBuilder.Entity<ExtraDeliveryCostByVolume>(entity =>
    {
      entity.Property<int>("Id").UseSqlServerIdentityColumn();
      entity.Property(x => x.ExtraDeliveryCost).HasColumnType("decimal(12,8)");
      entity.HasKey("Id");
      . . .

Further technical details

EF Core version: 1.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
IDE: Visual Studio 2015

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions