Skip to content

Conversation

@AndriySvyryd
Copy link
Member

Fixes #35382

Description
In EF9 we added a warning when applying migrations and the current model doesn't match the model snapshot from the latest migration. However, the migrations might be generated on a machine with a different OS than the machine that compiles the app. This results in a false positive warning if the model contains any multi-line strings.

Customer impact
If the user has configured warnings to throw by default, then this will result in an exception (usually on startup) in the above scenario. The workaround is to suppress this warning.

How found
This was reported by multiple users on EF9

Regression
Yes, from EF8

Testing
Tests added.

Risk
Low, only affects model diffing logic

@AndriySvyryd AndriySvyryd requested review from artl93 and Copilot August 27, 2025 01:09
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner August 27, 2025 01:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a cross-platform compatibility issue where EF9's migration model diffing incorrectly detected changes due to line ending differences between operating systems. The fix ensures that multi-line strings in models are compared while normalizing line endings.

Key changes:

  • Introduces a MultilineEquals helper method that normalizes line endings before string comparison
  • Updates all string comparisons in the MigrationsModelDiffer to use this normalized comparison for SQL and comment fields
  • Adds comprehensive test coverage for various scenarios involving line ending differences

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs Adds MultilineEquals helper and updates string comparisons to normalize line endings
test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs Adds comprehensive test cases covering line ending normalization scenarios
test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs Simplifies line ending normalization using ReplaceLineEndings()

Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rc2 previous regression

@AndriySvyryd AndriySvyryd merged commit a9f6488 into release/10.0 Aug 27, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the Issue35382 branch August 27, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model change detected because of newlines across Windows/Unix

5 participants