-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Issue summary
We have been using EF Core for 6 months now, and recently, after updating our project from 2.1 to 2.2, any new migration script has a ton of unexpected DropForeignKey, DropUniqueConstraint, DropColumn statements. Neither of the Keys, UniqueConstraints or Columns exists, so running this on the DB obviously fails. But this prevents us from creating new migrations.
I cannot come up with a small reproducible example, but I will try to share some patterns of the statements I noticed.
Issue details
All DROP COLUMN statements happen only for classes that are owned by parent classes that are owned by a grandparent (it has to be double owning, single not enough). By owning I mean something like that:
builder.OwnsOne(
nav => nav.MyCustomChildProperty, action =>
{
action.OwnsOne(nav => nav.MyCustomGrandChildProperty);
}
);
In all such scenarions, in my migration scripts, I would see DROP COLUMN statements like such:
MyCustomChildProperty_TempIdMyCustomChildProperty_TempId1(this one is a maybe)- ...
MyCustomChildProperty_MyCustomGrandChildProperty_TempIdMyCustomChildProperty_MyCustomGrandChildProperty_TempId1(this one is a maybe)MyCustomChildProperty_MyCustomGrandChildProperty_TempId2(this one is a maybe)- ...
and even weirder ones like: MyCustomChildProperty_MyCustomGrandChildProperty_MyCustomChildPropertyClassMyCustomClassId
Basically the pattern here is take class name of grandparent, add it to a grandparent class name, etc... and after reaching end, addIdto it.
I haven't tried to find a pattern for the other two types of statements (DropForeignKey, DropUniqueConstraint), but this seems that it should be related.
I tried deleting all of my migrations and creating a single fresh migration, and everything looks there as expected, therefore it seems that this is some bug that happens only if you already have some old migration scripts and trying to add a new one.
I have raised an SO question for this as well with no success.
Possibly relevant versions
We were running using 2.1 versions of dotnetcore andef core`.
Currently, my versions are:
dotnet --version=2.2.102dotnet ef --version=2.2.1-servicing-10028- Database Provider:
Microsoft.EntityFrameworkCore.SqlServer,v2.2.1 - OS: Windows 10