Skip to content

EF Core generates the same migration even though nothing has changed in the model #23792

Closed

Description

The issue seems to happen when the model combines owned entities with data seeding. I am sending a sample project reproducing the issue attached. I am using EF Core is 5.0.1.

The project contains a barebones ApplicationDbContext and a class implementing IEntityTypeConfiguration for an ApplicationUser class and another, almost empty, entity. For some reason, apparently the presence of a Guid field serving as an alternate key was also necessary to trigger the issue, but I could have been mistaken.

To reproduce the problem, run

add-migration a
add-migration b

and inspect the generated migrations. They are exactly the same, dropping and adding exactly the same tables and the same data (i.e. so in reality, both migrations should have been empty since nothing had changed in the model).

Include provider and version information

EF Core version: 5.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 10
IDE: 16.9 preview 1

repro-migrations.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions