diff --git a/src/EFCore/Properties/CoreStrings.Designer.cs b/src/EFCore/Properties/CoreStrings.Designer.cs index a481bcb514f..9623ce1884c 100644 --- a/src/EFCore/Properties/CoreStrings.Designer.cs +++ b/src/EFCore/Properties/CoreStrings.Designer.cs @@ -1862,7 +1862,7 @@ public static string InvalidEnumValue(object? value, object? argumentName, objec value, argumentName, enumType); /// - /// The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see https://go.microsoft.com/fwlink/?LinkID=746393. + /// The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a navigation property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see https://go.microsoft.com/fwlink/?LinkID=746393. /// public static string InvalidIncludeExpression(object? expression) => string.Format( diff --git a/src/EFCore/Properties/CoreStrings.resx b/src/EFCore/Properties/CoreStrings.resx index e84e4f08512..e1d654305bb 100644 --- a/src/EFCore/Properties/CoreStrings.resx +++ b/src/EFCore/Properties/CoreStrings.resx @@ -821,7 +821,7 @@ The value '{value}' provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'. - The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see https://go.microsoft.com/fwlink/?LinkID=746393. + The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a navigation property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see https://go.microsoft.com/fwlink/?LinkID=746393. Unable to track an entity of type '{entityType}' because its primary key property '{keyProperty}' is null. diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeQueryCosmosTest.cs index 5e4d89b10f1..5c35154bc34 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeQueryCosmosTest.cs @@ -108,6 +108,13 @@ FROM root c """); }); + public override async Task Include_complex_property(bool async) + { + await base.Include_complex_property(async); + + AssertSql(); + } + public override Task Complex_type_equals_complex_type(bool async) => CosmosTestHelpers.Instance.NoSyncTest( async, async async => diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeToJsonPropertyQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeToJsonPropertyQueryCosmosTest.cs index 8076ea87bc0..864a2977bca 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeToJsonPropertyQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ComplexTypeToJsonPropertyQueryCosmosTest.cs @@ -110,6 +110,13 @@ FROM root c """); }); + public override async Task Include_complex_property(bool async) + { + await base.Include_complex_property(async); + + AssertSql(); + } + public override Task Complex_type_equals_complex_type(bool async) => CosmosTestHelpers.Instance.NoSyncTest( async, async async => diff --git a/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs index e00ffb36177..37da1b51071 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs @@ -110,6 +110,14 @@ public virtual Task Select_complex_type_Distinct(bool async) async, ss => ss.Set().Select(c => c.ShippingAddress).Distinct()); + [Theory, MemberData(nameof(IsAsyncData))] + public virtual async Task Include_complex_property(bool async) + => Assert.Equal( + CoreStrings.InvalidIncludeExpression("c.ShippingAddress"), + (await Assert.ThrowsAsync(() => AssertQuery( + async, + ss => ss.Set().Include(c => c.ShippingAddress)))).Message); + [Theory, MemberData(nameof(IsAsyncData))] public virtual Task Complex_type_equals_complex_type(bool async) => AssertQuery( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs index 68661059aa4..3ec74f40d48 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs @@ -204,6 +204,13 @@ FROM [Customer] AS [c] """); } + public override async Task Include_complex_property(bool async) + { + await base.Include_complex_property(async); + + AssertSql(); + } + public override async Task Complex_type_equals_complex_type(bool async) { await base.Complex_type_equals_complex_type(async); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs index 38510fc64ba..a300bef0716 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs @@ -203,6 +203,13 @@ public override async Task Select_complex_type_Distinct(bool async) """); } + public override async Task Include_complex_property(bool async) + { + await base.Include_complex_property(async); + + AssertSql(); + } + public override async Task Complex_type_equals_complex_type(bool async) { await base.Complex_type_equals_complex_type(async);