-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple entities owning the same object hierarchy breaks migrations #26333
Comments
@smitpatel @AndriySvyryd While investigating this, I ran into the model validation error from #24573. However, this is a hard error instead of being a warning or a warning-treated-as-error. This seems wrong as it will block people updating with existing models.
|
@ajcvickers Yes, we decided that when the optional dependent has dependents of its own then we throw a normal exception because this could lead to data corruption. We should document this as a breaking change since it used to work in 3.1 - #12100 (comment) |
Filed docs issue dotnet/EntityFramework.Docs#3481 |
Description
Given a simple object hierarchy of object1->object2->object3 that is configured as an owned entity of 2 different regular entities causes migrations to break.
The first migration is generated correctly.
With or without changing anything following migrations generate statement that try to drop columns that don't exist.
Migrations were produced using the
dotnet-ef
tools version 5.0.11. (https://docs.microsoft.com/en-us/ef/core/cli/dotnet)Example:
Given this hierarchy:
And this configuration:
The first migration looks correct:
The second migration after that without changing any code produces the following erroneous statements:
Repo
A Repo to quickly demonstrate the bug can be found here:
https://github.com/Jejuni/EfCoreNestedOwnedEntitiesProblem
Migrations are already added.
To verify the problem simply delete the migrations and snapshot and run:
dotnet ef migrations add InitialMigration -o Migrations
dotnet ef migrations add NoChangeMigration -o Migrations
Include provider and version information
EF Core version: 5.0.11 (tested in 5.0.10 - 5.0.11)
dotnet-ef version 5.0.11
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.11.5
The text was updated successfully, but these errors were encountered: