11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4- using System ;
54using System . Diagnostics . CodeAnalysis ;
65using Microsoft . EntityFrameworkCore . ChangeTracking . Internal ;
76using Microsoft . EntityFrameworkCore . Internal ;
@@ -28,6 +27,10 @@ public class Property : PropertyBase, IMutableProperty, IConventionProperty, IPr
2827 private ConfigurationSource ? _valueGeneratedConfigurationSource ;
2928 private ConfigurationSource ? _typeMappingConfigurationSource ;
3029
30+ private static readonly bool QuirkEnabled29642
31+ = AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue29642" , out var enabled ) && enabled ;
32+
33+
3134 /// <summary>
3235 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
3336 /// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -670,6 +673,7 @@ public virtual PropertySaveBehavior GetAfterSaveBehavior()
670673 var property = this ;
671674 for ( var i = 0 ; i < 10000 ; i ++ )
672675 {
676+ var currentProperty = property ;
673677 foreach ( var foreignKey in property . GetContainingForeignKeys ( ) )
674678 {
675679 for ( var propertyIndex = 0 ; propertyIndex < foreignKey . Properties . Count ; propertyIndex ++ )
@@ -693,6 +697,12 @@ public virtual PropertySaveBehavior GetAfterSaveBehavior()
693697 }
694698 }
695699 }
700+
701+ if ( ! QuirkEnabled29642
702+ && currentProperty == property )
703+ {
704+ break ;
705+ }
696706 }
697707
698708 return null ;
@@ -749,6 +759,7 @@ public virtual PropertySaveBehavior GetAfterSaveBehavior()
749759 var property = this ;
750760 for ( var i = 0 ; i < 10000 ; i ++ )
751761 {
762+ var currentProperty = property ;
752763 foreach ( var foreignKey in property . GetContainingForeignKeys ( ) )
753764 {
754765 for ( var propertyIndex = 0 ; propertyIndex < foreignKey . Properties . Count ; propertyIndex ++ )
@@ -772,6 +783,12 @@ public virtual PropertySaveBehavior GetAfterSaveBehavior()
772783 }
773784 }
774785 }
786+
787+ if ( ! QuirkEnabled29642
788+ && currentProperty == property )
789+ {
790+ break ;
791+ }
775792 }
776793
777794 return null ;
0 commit comments