@@ -564,7 +564,7 @@ public virtual bool CanSetConversion(Type? providerClrType, ConfigurationSource?
564564 {
565565 if ( CanSetConverter ( converterType , configurationSource ) )
566566 {
567- Metadata . IsPrimitiveCollection ( false , configurationSource ) ;
567+ Metadata . ElementType ( false , configurationSource ) ;
568568 Metadata . SetProviderClrType ( null , configurationSource ) ;
569569 Metadata . SetValueConverter ( converterType , configurationSource ) ;
570570
@@ -776,11 +776,11 @@ public virtual bool CanSetProviderValueComparer(
776776 /// any release. You should only use it directly in your code with extreme caution and knowing that
777777 /// doing so can result in application failures when updating to a new Entity Framework Core release.
778778 /// </summary>
779- public virtual InternalElementTypeBuilder ? ElementType ( ConfigurationSource configurationSource )
779+ public virtual InternalElementTypeBuilder ? ElementType ( bool elementType , ConfigurationSource configurationSource )
780780 {
781- if ( CanSetElementType ( configurationSource ) )
781+ if ( CanSetElementType ( elementType , configurationSource ) )
782782 {
783- Metadata . IsPrimitiveCollection ( true , configurationSource ) ;
783+ Metadata . ElementType ( elementType , configurationSource ) ;
784784 Metadata . SetValueConverter ( ( Type ? ) null , configurationSource ) ;
785785 return new InternalElementTypeBuilder ( ( ElementType ) Metadata . GetElementType ( ) ! , ModelBuilder ) ;
786786 }
@@ -794,8 +794,9 @@ public virtual bool CanSetProviderValueComparer(
794794 /// any release. You should only use it directly in your code with extreme caution and knowing that
795795 /// doing so can result in application failures when updating to a new Entity Framework Core release.
796796 /// </summary>
797- public virtual bool CanSetElementType ( ConfigurationSource ? configurationSource )
798- => configurationSource . Overrides ( Metadata . GetElementTypeConfigurationSource ( ) ) ;
797+ public virtual bool CanSetElementType ( bool elementType , ConfigurationSource ? configurationSource )
798+ => configurationSource . Overrides ( Metadata . GetElementTypeConfigurationSource ( ) )
799+ && ( elementType != ( Metadata . GetElementType ( ) != null ) ) ;
799800
800801 /// <summary>
801802 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -905,10 +906,7 @@ public virtual bool CanSetElementType(ConfigurationSource? configurationSource)
905906 }
906907
907908 var oldElementType = ( ElementType ? ) Metadata . GetElementType ( ) ;
908- var oldElementTypeConfigurationSource = Metadata . GetElementTypeConfigurationSource ( ) ;
909- if ( oldElementType != null
910- && oldElementTypeConfigurationSource . HasValue
911- && newPropertyBuilder . CanSetElementType ( oldElementTypeConfigurationSource ) )
909+ if ( oldElementType != null )
912910 {
913911 var newElementType = ( ElementType ? ) newPropertyBuilder . Metadata . GetElementType ( ) ;
914912 if ( newElementType != null )
@@ -1525,16 +1523,15 @@ bool IConventionPropertyBuilder.CanSetProviderValueComparer(
15251523 /// any release. You should only use it directly in your code with extreme caution and knowing that
15261524 /// doing so can result in application failures when updating to a new Entity Framework Core release.
15271525 /// </summary>
1528- IConventionElementTypeBuilder ? IConventionPropertyBuilder . ElementType ( bool fromDataAnnotation )
1529- => ElementType ( fromDataAnnotation ? ConfigurationSource . DataAnnotation : ConfigurationSource . Convention ) ;
1526+ IConventionElementTypeBuilder ? IConventionPropertyBuilder . ElementType ( bool elementType , bool fromDataAnnotation )
1527+ => ElementType ( elementType , fromDataAnnotation ? ConfigurationSource . DataAnnotation : ConfigurationSource . Convention ) ;
15301528
15311529 /// <summary>
15321530 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
15331531 /// the same compatibility standards as public APIs. It may be changed or removed without notice in
15341532 /// any release. You should only use it directly in your code with extreme caution and knowing that
15351533 /// doing so can result in application failures when updating to a new Entity Framework Core release.
15361534 /// </summary>
1537- public virtual bool CanSetElementType ( bool fromDataAnnotation = false )
1538- => ( fromDataAnnotation ? ConfigurationSource . DataAnnotation : ConfigurationSource . Convention )
1539- . Overrides ( Metadata . GetElementTypeConfigurationSource ( ) ) ;
1535+ bool IConventionPropertyBuilder . CanSetElementType ( bool elementType , bool fromDataAnnotation )
1536+ => CanSetElementType ( elementType , fromDataAnnotation ? ConfigurationSource . DataAnnotation : ConfigurationSource . Convention ) ;
15401537}
0 commit comments