Skip to content

Conversation

AndriySvyryd
Copy link
Member

Fixes #32422
Port of #32573 and #32593

Description

The issue here is that when looking for foreign key property configuration we only detected relationship cycles if the initial property was part of the cycle. The fix is to keep updating the marker property as we traverse the relationships in increasing intervals. Additionally, we now detect multiple relationship chains that end with incompatible conversions.

Customer impact

Exception when trying to use a model that has a relationship cycle with a dangling relationship. The intended workaround of specifying the configuration explicitly doesn't work with migrations as this configuration is not stored.

How found

Customer report on 8.0.

Regression

Yes.

Testing

Tests added.

Risk

Low and quirked.

…hen not starting on one.

Additionally, detect multiple relationship chains that end with incompatible conversions.

Fixes #32422
@AndriySvyryd AndriySvyryd changed the base branch from main to release/8.0 December 12, 2023 19:26
@AndriySvyryd AndriySvyryd changed the title Improve the relationship cycle breaking logic to detect cycles even when not starting on one. [release/8.0] Improve the relationship cycle breaking logic to detect cycles even when not starting on one. Dec 12, 2023
@ajcvickers ajcvickers added this to the 8.0.2 milestone Dec 12, 2023
@wtgodbe
Copy link
Member

wtgodbe commented Jan 3, 2024

@AndriySvyryd can you get this reviewed? I can merge once it is

@maumar
Copy link
Contributor

maumar commented Jan 4, 2024

also ports HashHelpers introduced in #32124

@firasdarwish
Copy link

firasdarwish commented Apr 9, 2024

Hi @AndriySvyryd ,
I want to express my gratitude for your contribution.
I'd like to bring to your attention an issue I encountered with this feature in my project, which has 190 database entities
The validation and finalization time for the EF model is approx. 36 minutes on my i3-1115G4 (36 GB DDR4)
However, after disabling this feature using AppContext switch (Microsoft.EntityFrameworkCore.Issue32422), the time significantly reduced to it's original 3.5 seconds. It's worth noting that the project 'eventually' ran correctly in both scenarios, and I didn't encounter any memory issues like #33176

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

Successfully merging this pull request may close these issues.

Inconsistent behavior related to relationship cycle
5 participants