Skip to content

Commit f501b4c

Browse files
committed
Undo binary breaking change to INavigation
Fixes #21925
1 parent 769deff commit f501b4c

8 files changed

+118
-49
lines changed

src/EFCore/Metadata/IConventionNavigation.cs

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ public interface IConventionNavigation : INavigation, IConventionNavigationBase
2424
/// </summary>
2525
new IConventionNavigationBuilder Builder { get; }
2626

27+
/// <summary>
28+
/// Gets the type that this navigation property belongs to.
29+
/// </summary>
30+
new IConventionEntityType DeclaringEntityType
31+
{
32+
[DebuggerStepThrough]
33+
get => (IConventionEntityType)((INavigationBase)this).DeclaringEntityType;
34+
}
35+
36+
/// <summary>
37+
/// Gets the entity type that this navigation property will hold an instance(s) of.
38+
/// </summary>
39+
new IConventionEntityType TargetEntityType
40+
{
41+
[DebuggerStepThrough]
42+
get => (IConventionEntityType)((INavigationBase)this).TargetEntityType;
43+
}
44+
2745
/// <summary>
2846
/// Returns the configuration source for this navigation property.
2947
/// </summary>

src/EFCore/Metadata/IConventionNavigationBase.cs

-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata
1616
/// </summary>
1717
public interface IConventionNavigationBase : INavigationBase, IConventionPropertyBase
1818
{
19-
/// <summary>
20-
/// Gets the type that this navigation property belongs to.
21-
/// </summary>
22-
new IConventionEntityType DeclaringEntityType => (IConventionEntityType)((INavigationBase)this).DeclaringEntityType;
23-
24-
/// <summary>
25-
/// Gets the entity type that this navigation property will hold an instance(s) of.
26-
/// </summary>
27-
new IConventionEntityType TargetEntityType => (IConventionEntityType)((INavigationBase)this).TargetEntityType;
28-
29-
/// <summary>
30-
/// Gets the inverse navigation.
31-
/// </summary>
32-
new IConventionNavigationBase Inverse => (IConventionNavigationBase)((INavigationBase)this).Inverse;
33-
3419
/// <summary>
3520
/// Sets a value indicating whether this navigation should be eager loaded by default.
3621
/// </summary>

src/EFCore/Metadata/IConventionSkipNavigation.cs

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ public interface IConventionSkipNavigation : ISkipNavigation, IConventionNavigat
2424
/// </summary>
2525
new IConventionSkipNavigationBuilder Builder { get; }
2626

27+
/// <summary>
28+
/// Gets the type that this navigation property belongs to.
29+
/// </summary>
30+
new IConventionEntityType DeclaringEntityType
31+
{
32+
[DebuggerStepThrough]
33+
get => (IConventionEntityType)((INavigationBase)this).DeclaringEntityType;
34+
}
35+
36+
/// <summary>
37+
/// Gets the entity type that this navigation property will hold an instance(s) of.
38+
/// </summary>
39+
new IConventionEntityType TargetEntityType
40+
{
41+
[DebuggerStepThrough]
42+
get => (IConventionEntityType)((INavigationBase)this).TargetEntityType;
43+
}
44+
2745
/// <summary>
2846
/// Gets the join type used by the foreign key.
2947
/// </summary>

src/EFCore/Metadata/IMutableNavigation.cs

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ namespace Microsoft.EntityFrameworkCore.Metadata
1818
/// </summary>
1919
public interface IMutableNavigation : INavigation, IMutableNavigationBase
2020
{
21+
/// <summary>
22+
/// Gets the type that this navigation property belongs to.
23+
/// </summary>
24+
new IMutableEntityType DeclaringEntityType
25+
{
26+
[DebuggerStepThrough]
27+
get => (IMutableEntityType)((INavigationBase)this).DeclaringEntityType;
28+
}
29+
30+
/// <summary>
31+
/// Gets the entity type that this navigation property will hold an instance(s) of.
32+
/// </summary>
33+
new IMutableEntityType TargetEntityType
34+
{
35+
[DebuggerStepThrough]
36+
get => (IMutableEntityType)((INavigationBase)this).TargetEntityType;
37+
}
38+
2139
/// <summary>
2240
/// Gets the foreign key that defines the relationship this navigation property will navigate.
2341
/// </summary>

src/EFCore/Metadata/IMutableNavigationBase.cs

-27
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,6 @@ namespace Microsoft.EntityFrameworkCore.Metadata
1717
/// </summary>
1818
public interface IMutableNavigationBase : INavigationBase, IMutablePropertyBase
1919
{
20-
/// <summary>
21-
/// Gets the type that this navigation property belongs to.
22-
/// </summary>
23-
new IMutableEntityType DeclaringEntityType
24-
{
25-
[DebuggerStepThrough]
26-
get => (IMutableEntityType)((INavigationBase)this).DeclaringEntityType;
27-
}
28-
29-
/// <summary>
30-
/// Gets the entity type that this navigation property will hold an instance(s) of.
31-
/// </summary>
32-
new IMutableEntityType TargetEntityType
33-
{
34-
[DebuggerStepThrough]
35-
get => (IMutableEntityType)((INavigationBase)this).TargetEntityType;
36-
}
37-
38-
/// <summary>
39-
/// Gets the inverse skip navigation.
40-
/// </summary>
41-
new IMutableNavigationBase Inverse
42-
{
43-
[DebuggerStepThrough]
44-
get => (IMutableNavigationBase)((INavigationBase)this).Inverse;
45-
}
46-
4720
/// <summary>
4821
/// Sets a value indicating whether this navigation should be eager loaded by default.
4922
/// </summary>

src/EFCore/Metadata/IMutableSkipNavigation.cs

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ namespace Microsoft.EntityFrameworkCore.Metadata
1818
/// </summary>
1919
public interface IMutableSkipNavigation : ISkipNavigation, IMutableNavigationBase
2020
{
21+
/// <summary>
22+
/// Gets the type that this navigation property belongs to.
23+
/// </summary>
24+
new IMutableEntityType DeclaringEntityType
25+
{
26+
[DebuggerStepThrough]
27+
get => (IMutableEntityType)((INavigationBase)this).DeclaringEntityType;
28+
}
29+
30+
/// <summary>
31+
/// Gets the entity type that this navigation property will hold an instance(s) of.
32+
/// </summary>
33+
new IMutableEntityType TargetEntityType
34+
{
35+
[DebuggerStepThrough]
36+
get => (IMutableEntityType)((INavigationBase)this).TargetEntityType;
37+
}
38+
2139
/// <summary>
2240
/// Gets the join type used by the foreign key.
2341
/// </summary>

src/EFCore/Metadata/INavigation.cs

+43-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface INavigation : INavigationBase
1414
/// <summary>
1515
/// Gets the entity type that this navigation property belongs to.
1616
/// </summary>
17-
IEntityType INavigationBase.DeclaringEntityType
17+
new IEntityType DeclaringEntityType
1818
{
1919
[DebuggerStepThrough]
2020
get => IsOnDependent ? ForeignKey.DeclaringEntityType : ForeignKey.PrincipalEntityType;
@@ -23,7 +23,7 @@ IEntityType INavigationBase.DeclaringEntityType
2323
/// <summary>
2424
/// Gets the entity type that this navigation property will hold an instance(s) of.
2525
/// </summary>
26-
IEntityType INavigationBase.TargetEntityType
26+
new IEntityType TargetEntityType
2727
{
2828
[DebuggerStepThrough]
2929
get => IsOnDependent ? ForeignKey.PrincipalEntityType : ForeignKey.DeclaringEntityType;
@@ -39,12 +39,12 @@ IEntityType INavigationBase.TargetEntityType
3939
}
4040

4141
/// <summary>
42-
/// Gets the inverse navigation.
42+
/// Gets a value indicating whether the navigation property is a collection property.
4343
/// </summary>
44-
INavigationBase INavigationBase.Inverse
44+
new bool IsCollection
4545
{
4646
[DebuggerStepThrough]
47-
get => Inverse;
47+
get => !IsOnDependent && !ForeignKey.IsUnique;
4848
}
4949

5050
/// <summary>
@@ -61,13 +61,49 @@ bool IsOnDependent
6161
get => ForeignKey.DependentToPrincipal == this;
6262
}
6363

64+
/// <summary>
65+
/// Gets the <see cref="IClrCollectionAccessor" /> for this navigation property, if it's a collection
66+
/// navigation.
67+
/// </summary>
68+
/// <returns> The accessor. </returns>
69+
[DebuggerStepThrough]
70+
new IClrCollectionAccessor GetCollectionAccessor()
71+
=> ((Navigation)this).CollectionAccessor;
72+
73+
/// <summary>
74+
/// Gets the entity type that this navigation property belongs to.
75+
/// </summary>
76+
IEntityType INavigationBase.DeclaringEntityType
77+
{
78+
[DebuggerStepThrough]
79+
get => DeclaringEntityType;
80+
}
81+
82+
/// <summary>
83+
/// Gets the entity type that this navigation property will hold an instance(s) of.
84+
/// </summary>
85+
IEntityType INavigationBase.TargetEntityType
86+
{
87+
[DebuggerStepThrough]
88+
get => TargetEntityType;
89+
}
90+
91+
/// <summary>
92+
/// Gets the inverse navigation.
93+
/// </summary>
94+
INavigationBase INavigationBase.Inverse
95+
{
96+
[DebuggerStepThrough]
97+
get => Inverse;
98+
}
99+
64100
/// <summary>
65101
/// Gets a value indicating whether the navigation property is a collection property.
66102
/// </summary>
67103
bool INavigationBase.IsCollection
68104
{
69105
[DebuggerStepThrough]
70-
get => !IsOnDependent && !ForeignKey.IsUnique;
106+
get => IsCollection;
71107
}
72108

73109
/// <summary>
@@ -77,6 +113,6 @@ bool INavigationBase.IsCollection
77113
/// <returns> The accessor. </returns>
78114
[DebuggerStepThrough]
79115
IClrCollectionAccessor INavigationBase.GetCollectionAccessor()
80-
=> ((Navigation)this).CollectionAccessor;
116+
=> GetCollectionAccessor();
81117
}
82118
}

test/EFCore.Tests/ApiConsistencyTest.cs

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ public override bool TryGetProviderOptionsDelegate(out Action<DbContextOptionsBu
133133
typeof(EntityTypeExtensions).GetMethod(nameof(EntityTypeExtensions.GetProperty)),
134134
typeof(EntityTypeExtensions).GetMethod(nameof(EntityTypeExtensions.LeastDerivedType)),
135135
typeof(IConventionModelBuilder).GetMethod(nameof(IConventionModelBuilder.HasNoEntityType)),
136+
typeof(INavigationBase).GetMethod("get_DeclaringEntityType"),
137+
typeof(INavigationBase).GetMethod("get_TargetEntityType"),
138+
typeof(INavigationBase).GetMethod("get_Inverse"),
136139
typeof(IConventionAnnotatableBuilder).GetMethod(nameof(IConventionAnnotatableBuilder.HasNonNullAnnotation)),
137140
typeof(IConventionEntityTypeBuilder).GetMethod(nameof(IConventionEntityTypeBuilder.RemoveUnusedImplicitProperties)),
138141
typeof(IConventionEntityTypeBuilder).GetMethod(nameof(IConventionEntityTypeBuilder.Ignore)),

0 commit comments

Comments
 (0)