diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index a1fe408e31e..39ff2356057 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -929,8 +929,52 @@ protected virtual IEnumerable Diff( tm => string.Equals(sm.Property.Name, tm.Property.Name, StringComparison.OrdinalIgnoreCase) && EntityTypePathEquals(sm.Property.DeclaringType, tm.Property.DeclaringType, c))), + (s, t, _) => ColumnStructureEquals(s, t) && ColumnAnnotationsEqual(s, t, matchValues: true), + (s, t, _) => ColumnStructureEquals(s, t) && ColumnAnnotationsEqual(s, t, matchValues: false), (s, t, _) => ColumnStructureEquals(s, t)); + private static bool ColumnAnnotationsEqual(IColumn source, IColumn target, bool matchValues) + { + var sourceAnnotations = source.GetAnnotations().ToList(); + var targetAnnotations = target.GetAnnotations().ToList(); + + if (sourceAnnotations.Count != targetAnnotations.Count) + { + return false; + } + + foreach (var sourceAnnotation in sourceAnnotations) + { + var matchFound = false; + for (var i = 0; i < targetAnnotations.Count; i++) + { + var targetAnnotation = targetAnnotations[i]; + + if (sourceAnnotation.Name != targetAnnotation.Name) + { + continue; + } + + if (matchValues && sourceAnnotation.Value != targetAnnotation.Value) + { + continue; + } + + targetAnnotations.RemoveAt(i); + matchFound = true; + + break; + } + + if (!matchFound) + { + return false; + } + } + + return true; + } + private static bool ColumnStructureEquals(IColumn source, IColumn target) { if (!source.TryGetDefaultValue(out var sourceDefault)) diff --git a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs index c7b19f94799..6db0a1f3cf2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs @@ -8429,7 +8429,7 @@ await Test( """); } - [ConditionalFact(Skip = "issue #29902")] + [ConditionalFact] public virtual async Task Change_names_of_period_columns_in_temporal_table() { await Test(