diff --git a/src/EFCore.Relational/Metadata/Conventions/TableSharingConcurrencyTokenConvention.cs b/src/EFCore.Relational/Metadata/Conventions/TableSharingConcurrencyTokenConvention.cs index 9c4aa0f9c41..fb4415cd807 100644 --- a/src/EFCore.Relational/Metadata/Conventions/TableSharingConcurrencyTokenConvention.cs +++ b/src/EFCore.Relational/Metadata/Conventions/TableSharingConcurrencyTokenConvention.cs @@ -234,31 +234,24 @@ public static bool IsConcurrencyTokenMissing( private static void RemoveDerivedEntityTypes(Dictionary entityTypeDictionary) { - var toRemove = new HashSet>(); var entityTypesWithDerivedTypes = - entityTypeDictionary.Where(e => e.Key.GetDirectlyDerivedTypes().Any()).ToList(); + entityTypeDictionary.Where(e => e.Key.GetDirectlyDerivedTypes().Any()); foreach (var entityType in entityTypeDictionary.Where(e => e.Key.BaseType != null)) { foreach (var otherEntityType in entityTypesWithDerivedTypes) { - if (toRemove.Contains(otherEntityType) - || otherEntityType.Equals(entityType)) + if (otherEntityType.Equals(entityType)) { continue; } if (otherEntityType.Key.IsAssignableFrom(entityType.Key)) { - toRemove.Add(entityType); + entityTypeDictionary.Remove(entityType.Key); break; } } } - - foreach (var entityType in toRemove) - { - entityTypeDictionary.Remove(entityType.Key); - } } } } diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs index b727774930b..a31267774de 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs @@ -701,7 +701,7 @@ private NavigationExpansionExpression ProcessCastOfType( var siblingNavigations = newEntityReference.IncludePaths.Keys .Where( n => !castEntityType.IsAssignableFrom(n.DeclaringEntityType) - && !n.DeclaringEntityType.IsAssignableFrom(castEntityType)).ToList(); + && !n.DeclaringEntityType.IsAssignableFrom(castEntityType)); foreach (var navigation in siblingNavigations) {