[rc2] Ignore line endings when comparing strings in MigrationsModelDiffer#36664
Merged
AndriySvyryd merged 1 commit intorelease/10.0from Aug 27, 2025
Merged
[rc2] Ignore line endings when comparing strings in MigrationsModelDiffer#36664AndriySvyryd merged 1 commit intorelease/10.0from
AndriySvyryd merged 1 commit intorelease/10.0from
Conversation
There was a problem hiding this comment.
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
MultilineEqualshelper 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() |
d2df3aa to
0a26daf
Compare
roji
approved these changes
Aug 27, 2025
cincuranet
approved these changes
Aug 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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