[release/9.0-staging] Fix to #35108 - Temporal table migration regression from EF Core 8 to 9#35289
Merged
maumar merged 1 commit intorelease/9.0-stagingfrom Dec 10, 2024
Merged
Conversation
In 9 we changed the way we process migration of temporal tables. One of the changes was drastically reducing the number of annotations for columns which are part of temporal tables. This however caused regressions for cases where migration code was created using EF8 (and containing those legacy annotations) but then executed using EF9 tooling. Specifically, extra annotations were generating a number of superfluous Alter Column operations (which were only modifying those annotations). In EF8 we had logic to weed out those operations, but it was removed in EF9. Fix is to remove all the legacy annotations on column operations before we start processing them. We no longer rely on them, but rather use annotations on Table operations and/or relational model. The only exception is CreateColumnOperation, so for it we convert old annotations to TemporalIsPeriodStartColumn and TemporalIsPeriodEndColumn where appropriate. Also, we are bringing back logic from EF8 which removed unnecessary AlterColumnOperations if the old and new columns are the same after the legacy temporal annotations have been removed.
AndriySvyryd
approved these changes
Dec 10, 2024
Contributor
Author
|
approved by email |
1 task
This was referenced Jul 22, 2025
Closed
This was referenced Mar 16, 2026
Merged
Merged
This was referenced Mar 25, 2026
Merged
Open
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.
Port of #35283
Fixes #35108
Description
In 9 we changed the way we process migration of temporal tables. One of the changes was drastically reducing the number of annotations for columns which are part of temporal tables. This however caused regressions for cases where migration code was created using EF8 (and containing those legacy annotations) but then executed using EF9 tooling. Specifically, extra annotations were generating a number of superfluous Alter Column operations (which were only modifying those annotations). In EF8 we had logic to weed out those operations, but it was removed in EF9.
Customer impact
Customers using temporal tables, who created migrations with EF Core 8 will see exception when trying to execute those migrations with EF Core 9 tooling. Workaround is to manually modify the migration code, but the solution is not obvious.
How found
Multiple customer reports on 9.0 bits
Regression
Yes, these migrations worked fine in EF 8.0
Testing
Extensive tests added for reported scenarios as well as other common temporal operations.
Risk
Low. Only the legacy scenarios are affected, so we should not regress 9.0 scenarios any further. We essentially normalize the old annotations so that old migration operations resemble the new ones and work well with the current logic. Also brought back some code from EF8 to filter redundant migration operations (so that code as been tested in EF8 already).