File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ public class ForeignKeyPropertyDiscoveryConvention :
5050 IPropertyFieldChangedConvention ,
5151 IModelFinalizingConvention
5252{
53+ private static readonly bool UseOldBehavior35110 =
54+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35110" , out var enabled ) && enabled ;
55+
5356 /// <summary>
5457 /// Creates a new instance of <see cref="ForeignKeyPropertyDiscoveryConvention" />.
5558 /// </summary>
@@ -81,7 +84,8 @@ private IConventionForeignKeyBuilder ProcessForeignKey(
8184 IConventionContext context )
8285 {
8386 var shouldBeRequired = true ;
84- if ( ! relationshipBuilder . Metadata . IsOwnership )
87+ if ( ! relationshipBuilder . Metadata . IsOwnership
88+ || UseOldBehavior35110 )
8589 {
8690 foreach ( var property in relationshipBuilder . Metadata . Properties )
8791 {
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Internal;
1515/// </summary>
1616public class InternalEntityTypeBuilder : InternalTypeBaseBuilder , IConventionEntityTypeBuilder
1717{
18+ private static readonly bool UseOldBehavior35110 =
19+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35110" , out var enabled ) && enabled ;
20+
1821 /// <summary>
1922 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
2023 /// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -3171,8 +3174,12 @@ public static InternalIndexBuilder DetachIndex(Index indexToDetach)
31713174 + "Owned types should only have ownership or ownee navigations point at it" ) ;
31723175
31733176 relationship = relationship . IsOwnership ( true , configurationSource )
3174- ? . HasNavigations ( inverse , navigation , configurationSource )
3175- ? . IsRequired ( true , configurationSource ) ;
3177+ ? . HasNavigations ( inverse , navigation , configurationSource ) ;
3178+
3179+ if ( ! UseOldBehavior35110 )
3180+ {
3181+ relationship = relationship ? . IsRequired ( true , configurationSource ) ;
3182+ }
31763183
31773184 relationship ? . Metadata . UpdateConfigurationSource ( configurationSource ) ;
31783185 return relationship ;
You can’t perform that action at this time.
0 commit comments