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 :
50
50
IPropertyFieldChangedConvention ,
51
51
IModelFinalizingConvention
52
52
{
53
+ private static readonly bool UseOldBehavior35110 =
54
+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35110" , out var enabled ) && enabled ;
55
+
53
56
/// <summary>
54
57
/// Creates a new instance of <see cref="ForeignKeyPropertyDiscoveryConvention" />.
55
58
/// </summary>
@@ -81,7 +84,8 @@ private IConventionForeignKeyBuilder ProcessForeignKey(
81
84
IConventionContext context )
82
85
{
83
86
var shouldBeRequired = true ;
84
- if ( ! relationshipBuilder . Metadata . IsOwnership )
87
+ if ( ! relationshipBuilder . Metadata . IsOwnership
88
+ || UseOldBehavior35110 )
85
89
{
86
90
foreach ( var property in relationshipBuilder . Metadata . Properties )
87
91
{
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Internal;
15
15
/// </summary>
16
16
public class InternalEntityTypeBuilder : InternalTypeBaseBuilder , IConventionEntityTypeBuilder
17
17
{
18
+ private static readonly bool UseOldBehavior35110 =
19
+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35110" , out var enabled ) && enabled ;
20
+
18
21
/// <summary>
19
22
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
20
23
/// 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)
3171
3174
+ "Owned types should only have ownership or ownee navigations point at it" ) ;
3172
3175
3173
3176
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
+ }
3176
3183
3177
3184
relationship ? . Metadata . UpdateConfigurationSource ( configurationSource ) ;
3178
3185
return relationship ;
You can’t perform that action at this time.
0 commit comments