diff --git a/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs index d5d6be71940..29c197a565d 100644 --- a/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs @@ -619,6 +619,14 @@ bool CanAddNavigation([NotNull] string navigationName, bool fromDataAnnotation = /// if the configuration can be applied. bool CanHaveNavigation([NotNull] string navigationName, bool fromDataAnnotation = false); + /// + /// Returns a value indicating whether the given navigation base can be added to this entity type. + /// + /// The name of the navigation base. + /// Indicates whether the configuration was specified using a data annotation. + /// if the configuration can be applied. + bool CanHaveNavigationBase([NotNull] string navigationBaseName, bool fromDataAnnotation = false); + /// /// Configures a skip navigation and the inverse between this and the target entity type. /// diff --git a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs index a417285dca5..af770250769 100644 --- a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs @@ -53,7 +53,7 @@ private void Process( IConventionEntityTypeBuilder entityTypeBuilder, MemberInfo navigationMemberInfo, Type targetClrType, InversePropertyAttribute attribute) { - if (!entityTypeBuilder.CanHaveNavigation( + if (!entityTypeBuilder.CanHaveNavigationBase( navigationMemberInfo.GetSimpleMemberName(), fromDataAnnotation: true)) { return; @@ -137,53 +137,88 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( if (ambiguousInverse != null) { - var existingInverse = targetEntityTypeBuilder.Metadata.FindNavigation(inverseNavigationPropertyInfo)?.Inverse; - var existingInverseType = existingInverse?.DeclaringEntityType; - if (existingInverse != null - && IsAmbiguousInverse( - existingInverse.GetIdentifyingMemberInfo(), existingInverseType, referencingNavigationsWithAttribute)) + if (entityType.FindSkipNavigation(navigationMemberInfo) is IConventionSkipNavigation existingSkipNavigation) { - var fk = existingInverse.ForeignKey; - if (fk.IsOwnership - || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + var inverseSkipNavigation = targetEntityTypeBuilder.Metadata.FindSkipNavigation(inverseNavigationPropertyInfo); + if (inverseSkipNavigation != null) { - fk.Builder.HasNavigation( - (string)null, - existingInverse.IsOnDependent, - fromDataAnnotation: true); + if (inverseSkipNavigation.Inverse == null + || inverseSkipNavigation.Inverse.Equals(existingSkipNavigation)) + { + existingSkipNavigation.Builder.HasInverse(inverseSkipNavigation, fromDataAnnotation: true); + } + else + { + var existingInverseSkipnavigation = inverseSkipNavigation.Inverse; + + entityType.Builder.HasNoSkipNavigation(existingSkipNavigation, fromDataAnnotation: true); + inverseSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + inverseSkipNavigation, fromDataAnnotation: true); + existingInverseSkipnavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + existingInverseSkipnavigation, fromDataAnnotation: true); + } } - } - var existingNavigation = entityType.FindNavigation(navigationMemberInfo); - if (existingNavigation != null) - { - var fk = existingNavigation.ForeignKey; - if (fk.IsOwnership - || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + var ambiguousInverseSkipNavigation = FindActualEntityType(ambiguousInverse.Value.Item2) + .FindSkipNavigation(ambiguousInverse.Value.Item1); + if (ambiguousInverseSkipNavigation != null) { - fk.Builder.HasNavigation( - (string)null, - existingNavigation.IsOnDependent, - fromDataAnnotation: true); + ambiguousInverseSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + ambiguousInverseSkipNavigation, fromDataAnnotation: true); } - } - var existingAmbiguousNavigation = FindActualEntityType(ambiguousInverse.Value.Item2) - .FindNavigation(ambiguousInverse.Value.Item1); - if (existingAmbiguousNavigation != null) + throw new InvalidOperationException("Issue#21890"); + } + else { - var fk = existingAmbiguousNavigation.ForeignKey; - if (fk.IsOwnership - || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + var existingInverse = targetEntityTypeBuilder.Metadata.FindNavigation(inverseNavigationPropertyInfo)?.Inverse; + var existingInverseType = existingInverse?.DeclaringEntityType; + if (existingInverse != null + && IsAmbiguousInverse( + existingInverse.GetIdentifyingMemberInfo(), existingInverseType, referencingNavigationsWithAttribute)) { - fk.Builder.HasNavigation( - (string)null, - existingAmbiguousNavigation.IsOnDependent, - fromDataAnnotation: true); + var fk = existingInverse.ForeignKey; + if (fk.IsOwnership + || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + { + fk.Builder.HasNavigation( + (string)null, + existingInverse.IsOnDependent, + fromDataAnnotation: true); + } + } + + var existingNavigation = entityType.FindNavigation(navigationMemberInfo); + if (existingNavigation != null) + { + var fk = existingNavigation.ForeignKey; + if (fk.IsOwnership + || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + { + fk.Builder.HasNavigation( + (string)null, + existingNavigation.IsOnDependent, + fromDataAnnotation: true); + } } - } - return entityType.FindNavigation(navigationMemberInfo)?.ForeignKey.Builder; + var existingAmbiguousNavigation = FindActualEntityType(ambiguousInverse.Value.Item2) + .FindNavigation(ambiguousInverse.Value.Item1); + if (existingAmbiguousNavigation != null) + { + var fk = existingAmbiguousNavigation.ForeignKey; + if (fk.IsOwnership + || fk.DeclaringEntityType.Builder.HasNoRelationship(fk, fromDataAnnotation: true) == null) + { + fk.Builder.HasNavigation( + (string)null, + existingAmbiguousNavigation.IsOnDependent, + fromDataAnnotation: true); + } + } + + return entityType.FindNavigation(navigationMemberInfo)?.ForeignKey.Builder; + } } var ownership = entityType.FindOwnership(); @@ -195,6 +230,7 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( entityType, navigationMemberInfo, targetEntityTypeBuilder.Metadata, inverseNavigationPropertyInfo, ownership.PrincipalToDependent?.GetIdentifyingMemberInfo()); + return null; } @@ -206,21 +242,45 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( entityType, navigationMemberInfo, targetEntityTypeBuilder.Metadata, inverseNavigationPropertyInfo, entityType.DefiningEntityType.GetRuntimeProperties()[entityType.DefiningNavigationName]); + return null; } - return entityType.Model.FindIsOwnedConfigurationSource(entityType.ClrType) != null - && !entityType.IsInOwnershipPath(targetEntityTypeBuilder.Metadata) - ? targetEntityTypeBuilder.HasOwnership( - entityTypeBuilder.Metadata.ClrType, - inverseNavigationPropertyInfo, - navigationMemberInfo, - fromDataAnnotation: true) - : targetEntityTypeBuilder.HasRelationship( - entityType, - inverseNavigationPropertyInfo, - navigationMemberInfo, - fromDataAnnotation: true); + if (entityType.Model.FindIsOwnedConfigurationSource(entityType.ClrType) != null + && !entityType.IsInOwnershipPath(targetEntityTypeBuilder.Metadata)) + { + return targetEntityTypeBuilder.HasOwnership( + entityTypeBuilder.Metadata.ClrType, + inverseNavigationPropertyInfo, + navigationMemberInfo, + fromDataAnnotation: true); + } + else + { + var newForeignKeyBuilder = targetEntityTypeBuilder.HasRelationship( + entityType, + inverseNavigationPropertyInfo, + navigationMemberInfo, + fromDataAnnotation: true); + + if (newForeignKeyBuilder == null + && navigationMemberInfo is PropertyInfo navigationPropertyInfo) + { + var navigationTargetType = navigationPropertyInfo.PropertyType.TryGetSequenceType(); + var inverseNavigationTargetType = inverseNavigationPropertyInfo.PropertyType.TryGetSequenceType(); + if (navigationTargetType != null + && inverseNavigationTargetType != null + && navigationTargetType.IsAssignableFrom(targetClrType) + && inverseNavigationTargetType.IsAssignableFrom(entityType.ClrType)) + { + entityTypeBuilder.HasSkipNavigation( + navigationPropertyInfo, targetEntityTypeBuilder.Metadata, + inverseNavigationPropertyInfo, collections: true, onDependent: false, fromDataAnnotation: true); + } + } + + return newForeignKeyBuilder; + } } /// @@ -472,9 +532,9 @@ private static (MemberInfo, IConventionEntityType)? FindAmbiguousInverse( foreach (var referencingTuple in referencingNavigationsWithAttribute) { var inverseTargetEntityType = FindActualEntityType(referencingTuple.TargetEntityType); - if ((inverseTargetEntityType?.Builder.IsIgnored( + if (inverseTargetEntityType?.Builder.IsIgnored( referencingTuple.Inverse.GetSimpleMemberName(), fromDataAnnotation: true) - != false)) + != false) { if (tuplesToRemove == null) { diff --git a/src/EFCore/Metadata/Conventions/ManyToManyAssociationEntityTypeConvention.cs b/src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs similarity index 100% rename from src/EFCore/Metadata/Conventions/ManyToManyAssociationEntityTypeConvention.cs rename to src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs diff --git a/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs b/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs index 72d995d9047..59c2257de53 100644 --- a/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs @@ -968,6 +968,18 @@ public virtual bool CanHaveNavigation([NotNull] string navigationName, Configura .Concat(Metadata.FindSkipNavigationsInHierarchy(navigationName)) .All(m => configurationSource.Overrides(m.GetConfigurationSource())); + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public virtual bool CanHaveNavigationBase([NotNull] string skipNavigationName, ConfigurationSource? configurationSource) + => !IsIgnored(skipNavigationName, configurationSource) + && Metadata.FindPropertiesInHierarchy(skipNavigationName).Cast() + .Concat(Metadata.FindServicePropertiesInHierarchy(skipNavigationName)) + .All(m => configurationSource.Overrides(m.GetConfigurationSource())); + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in @@ -4871,6 +4883,18 @@ bool IConventionEntityTypeBuilder.CanHaveNavigation(string navigationName, bool navigationName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + [DebuggerStepThrough] + bool IConventionEntityTypeBuilder.CanHaveNavigationBase(string navigationBaseName, bool fromDataAnnotation) + => CanHaveNavigationBase( + navigationBaseName, + fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + /// [DebuggerStepThrough] IConventionSkipNavigationBuilder IConventionEntityTypeBuilder.HasSkipNavigation( diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs index 6668dfe248b..4ef8e257719 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs @@ -171,8 +171,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .WithMany(e => e.OneSkip) .UsingEntity( r => r.HasOne().WithMany().HasForeignKey(e => e.TwoId), - l => l.HasOne().WithMany().HasForeignKey(e => e.OneId)) - .HasKey(e => new { e.OneId, e.TwoId }); + l => l.HasOne().WithMany().HasForeignKey(e => e.OneId)); // Nav:6 Payload:Yes Join:Concrete Extra:None modelBuilder.Entity() @@ -180,11 +179,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .WithMany(e => e.OneSkipPayloadFull) .UsingEntity( r => r.HasOne(x => x.Three).WithMany(e => e.JoinOnePayloadFull), - l => l.HasOne(x => x.One).WithMany(e => e.JoinThreePayloadFull)) - .HasKey(e => new { e.OneId, e.ThreeId }); - - // Nav:2 Payload:No Join:Shared Extra:None - modelBuilder.Entity().HasMany(e => e.TwoSkipShared).WithMany(e => e.OneSkipShared); + l => l.HasOne(x => x.One).WithMany(e => e.JoinThreePayloadFull)); // Nav:4 Payload:Yes Join:Shared Extra:None modelBuilder.Entity() @@ -202,17 +197,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .WithMany(e => e.SelfSkipPayloadRight) .UsingEntity( l => l.HasOne(x => x.Left).WithMany(x => x.JoinSelfPayloadLeft), - r => r.HasOne(x => x.Right).WithMany(x => x.JoinSelfPayloadRight).OnDelete(DeleteBehavior.ClientCascade)) - .HasKey(e => new { e.LeftId, e.RightId }); + r => r.HasOne(x => x.Right).WithMany(x => x.JoinSelfPayloadRight).OnDelete(DeleteBehavior.ClientCascade)); // Nav:2 Payload:No Join:Concrete Extra:Inheritance modelBuilder.Entity() .HasMany(e => e.BranchSkip) .WithMany(e => e.OneSkip) .UsingEntity( - r => r.HasOne().WithMany().HasForeignKey(e => e.BranchId), - l => l.HasOne().WithMany().HasForeignKey(e => e.OneId)) - .HasKey(e => new { e.BranchId, e.OneId }); + r => r.HasOne().WithMany(), + l => l.HasOne().WithMany()); modelBuilder.Entity() .HasOne(e => e.Reference) @@ -230,8 +223,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .WithMany(e => e.TwoSkipFull) .UsingEntity( r => r.HasOne(x => x.Three).WithMany(e => e.JoinTwoFull), - l => l.HasOne(x => x.Two).WithMany(e => e.JoinThreeFull)) - .HasKey(e => new { e.TwoId, e.ThreeId }); + l => l.HasOne(x => x.Two).WithMany(e => e.JoinThreeFull)); // Nav:2 Payload:No Join:Shared Extra:Self-ref modelBuilder.Entity() @@ -261,9 +253,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con r => r.HasOne(x => x.Three).WithMany(x => x.JoinCompositeKeyFull)) .HasKey(e => new { e.ThreeId, e.CompositeId1, e.CompositeId2, e.CompositeId3 }); - // Nav:2 Payload:No Join:Shared Extra:Inheritance - modelBuilder.Entity().HasMany(e => e.RootSkipShared).WithMany(e => e.ThreeSkipShared); - // TODO: convert to shared type // Nav:2 Payload:No Join:Shared Extra:Inheritance,CompositeKey modelBuilder.Entity() diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs index 80395c1d2c9..83e17c5f437 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; namespace Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel { @@ -21,6 +22,7 @@ public class EntityOne public virtual ICollection JoinThreePayloadFull { get; } = new ObservableCollection(); // #21684 + [InverseProperty("OneSkipShared")] public virtual ICollection TwoSkipShared { get; } = new ObservableCollection(); // #21684 public virtual ICollection ThreeSkipPayloadFullShared { get; } = new ObservableCollection(); // #21684 diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs index bcf6a595691..1cd8c56d7d3 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; namespace Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel { @@ -36,6 +37,7 @@ public class EntityThree public virtual ICollection JoinCompositeKeyFull { get; } = new ObservableCollection(); // #21684 + [InverseProperty("ThreeSkipShared")] public virtual ICollection RootSkipShared { get; } = new ObservableCollection(); // #21684 } } diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityTwo.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityTwo.cs index 4118927e8de..9473feb2bbd 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityTwo.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityTwo.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; namespace Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel { @@ -25,6 +26,7 @@ public class EntityTwo public virtual ICollection SelfSkipSharedLeft { get; } = new ObservableCollection(); // #21684 public virtual ICollection SelfSkipSharedRight { get; } = new ObservableCollection(); // #21684 + [InverseProperty("TwoSkipShared")] public virtual ICollection OneSkipShared { get; } = new ObservableCollection(); // #21684 public virtual ICollection CompositeKeySkipShared { get; } diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/JoinOneToBranch.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/JoinOneToBranch.cs index c2f6863ae62..879ba693125 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/JoinOneToBranch.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/JoinOneToBranch.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel { public class JoinOneToBranch { - public virtual int OneId { get; set; } - public virtual int BranchId { get; set; } + public virtual int EntityOneId { get; set; } + public virtual int EntityBranchId { get; set; } } } diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs index 0997f3cb77e..79e25bed516 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs @@ -117,8 +117,8 @@ public ManyToManyData() foreach (var joinEntity in _joinOneToBranches) { - var one = _ones.First(o => o.Id == joinEntity.OneId); - var branch = _roots.OfType().First(t => t.Id == joinEntity.BranchId); + var one = _ones.First(o => o.Id == joinEntity.EntityOneId); + var branch = _roots.OfType().First(t => t.Id == joinEntity.EntityBranchId); one.BranchSkip.Add(branch); branch.OneSkip.Add(one); } @@ -629,8 +629,8 @@ private static JoinOneToBranch CreateJoinOneToBranch( => CreateInstance( context?.Set(), e => { - e.OneId = oneId; - e.BranchId = branchId; + e.EntityOneId = oneId; + e.EntityBranchId = branchId; }); private static JoinOneToThreePayloadFull[] CreateJoinOneToThreePayloadFulls(ManyToManyContext context) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs index 47dc42d3300..a48eafc2629 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs @@ -102,8 +102,8 @@ INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t] ON [j].[BranchId] = [t].[Id] - WHERE ([e].[Id] = [j].[OneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] + WHERE ([e].[Id] = [j].[EntityOneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); } public override async Task Skip_navigation_long_count_without_predicate(bool async) @@ -289,14 +289,14 @@ public override async Task Skip_navigation_order_by_last_or_default(bool async) @"SELECT [t0].[Id], [t0].[Name] FROM [EntityRoots] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[Name], [t].[BranchId], [t].[OneId] + SELECT [t].[Id], [t].[Name], [t].[EntityBranchId], [t].[EntityOneId] FROM ( - SELECT [e0].[Id], [e0].[Name], [j].[BranchId], [j].[OneId], ROW_NUMBER() OVER(PARTITION BY [j].[BranchId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[Name], [j].[EntityBranchId], [j].[EntityOneId], ROW_NUMBER() OVER(PARTITION BY [j].[EntityBranchId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinOneToBranch] AS [j] - INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] + INNER JOIN [EntityOnes] AS [e0] ON [j].[EntityOneId] = [e0].[Id] ) AS [t] WHERE [t].[row] <= 1 -) AS [t0] ON [e].[Id] = [t0].[BranchId] +) AS [t0] ON [e].[Id] = [t0].[EntityBranchId] WHERE [e].[Discriminator] IN (N'EntityBranch', N'EntityLeaf')"); } @@ -308,9 +308,9 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -494,14 +494,14 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) @"SELECT [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] FROM [EntityOnes] AS [e] INNER JOIN ( - SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[BranchId], [j].[OneId] + SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[EntityBranchId], [j].[EntityOneId] FROM [JoinOneToBranch] AS [j] INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t] ON [j].[BranchId] = [t].[Id] -) AS [t0] ON [e].[Id] = [t0].[OneId]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] +) AS [t0] ON [e].[Id] = [t0].[EntityOneId]"); } public override async Task Select_skip_navigation(bool async) @@ -524,10 +524,10 @@ public override async Task Select_skip_navigation_multiple(bool async) await base.Select_skip_navigation_multiple(async); AssertSql( - @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] + @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] FROM [EntityTwos] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e0] ON [j].[ThreeId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[TwoId] @@ -541,7 +541,7 @@ LEFT JOIN ( FROM [JoinTwoToCompositeKeyShared] AS [j1] INNER JOIN [EntityCompositeKeys] AS [e2] ON (([j1].[CompositeId1] = [e2].[Key1]) AND ([j1].[CompositeId2] = [e2].[Key2])) AND ([j1].[CompositeId3] = [e2].[Key3]) ) AS [t1] ON [e].[Id] = [t1].[TwoId] -ORDER BY [e].[Id], [t].[TwoId], [t].[ThreeId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); +ORDER BY [e].[Id], [t].[ThreeId], [t].[TwoId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); } public override async Task Select_skip_navigation_first_or_default(bool async) @@ -599,10 +599,10 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( await base.Include_skip_navigation_then_include_skip_navigation(async); AssertSql( - @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id0], [t1].[Name0], [t1].[BranchId], [t1].[OneId] + @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id0], [t1].[Name0], [t1].[EntityBranchId], [t1].[EntityOneId] FROM [EntityCompositeKeys] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0], [t0].[BranchId], [t0].[OneId] + SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0], [t0].[EntityBranchId], [t0].[EntityOneId] FROM [JoinCompositeKeyToLeaf] AS [j] INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] @@ -610,12 +610,12 @@ FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] = N'EntityLeaf' ) AS [t] ON [j].[LeafId] = [t].[Id] LEFT JOIN ( - SELECT [e1].[Id], [e1].[Name], [j0].[BranchId], [j0].[OneId] + SELECT [e1].[Id], [e1].[Name], [j0].[EntityBranchId], [j0].[EntityOneId] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e1] ON [j0].[OneId] = [e1].[Id] - ) AS [t0] ON [t].[Id] = [t0].[BranchId] + INNER JOIN [EntityOnes] AS [e1] ON [j0].[EntityOneId] = [e1].[Id] + ) AS [t0] ON [t].[Id] = [t0].[EntityBranchId] ) AS [t1] ON (([e].[Key1] = [t1].[CompositeId1]) AND ([e].[Key2] = [t1].[CompositeId2])) AND ([e].[Key3] = [t1].[CompositeId3]) -ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[BranchId], [t1].[OneId], [t1].[Id0]"); +ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0]"); } public override async Task Include_skip_navigation_then_include_reference_and_skip_navigation(bool async) @@ -676,14 +676,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) await base.Filtered_include_skip_navigation_order_by(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[ThreeId] -ORDER BY [e].[Id], [t].[Id], [t].[TwoId], [t].[ThreeId]"); +ORDER BY [e].[Id], [t].[Id], [t].[ThreeId], [t].[TwoId]"); } public override async Task Filtered_include_skip_navigation_order_by_skip(bool async) @@ -815,10 +815,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t await base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[TwoId0], [t1].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[ThreeId], [t1].[TwoId0] FROM [EntityOnes] AS [e] OUTER APPLY ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[OneId], [t].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[OneId], [t].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0] FROM ( SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId] FROM [JoinOneToTwo] AS [j] @@ -828,13 +828,13 @@ ORDER BY [e0].[Id] OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY ) AS [t] LEFT JOIN ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[TwoId], [j0].[ThreeId] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[ThreeId], [j0].[TwoId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 ) AS [t0] ON [t].[Id] = [t0].[TwoId] ) AS [t1] -ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0]"); +ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0]"); } public override async Task Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(bool async) @@ -842,16 +842,16 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s await base.Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[TwoId0], [t1].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[ThreeId], [t1].[TwoId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0] FROM [JoinOneToTwo] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[TwoId], [j0].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[ThreeId], [j0].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t] @@ -885,10 +885,10 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte await base.Filter_include_on_skip_navigation_combined_with_filtered_then_includes(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[Id], [t3].[Name], [t3].[OneId], [t3].[ThreeId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[OneId0], [t3].[TwoId], [t3].[Id1], [t3].[Discriminator], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[BranchId], [t3].[OneId1] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[Id], [t3].[Name], [t3].[OneId], [t3].[ThreeId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[OneId0], [t3].[TwoId], [t3].[Id1], [t3].[Discriminator], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[EntityBranchId], [t3].[EntityOneId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[Name], [j].[OneId], [j].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t2].[Id] AS [Id1], [t2].[Discriminator], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[BranchId], [t2].[OneId] AS [OneId1] + SELECT [e0].[Id], [e0].[Name], [j].[OneId], [j].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t2].[Id] AS [Id1], [t2].[Discriminator], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[EntityBranchId], [t2].[EntityOneId] FROM [JoinOneToThreePayloadFull] AS [j] INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] LEFT JOIN ( @@ -901,18 +901,18 @@ FROM [JoinOneToTwo] AS [j0] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e0].[Id] = [t0].[OneId] LEFT JOIN ( - SELECT [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [j1].[BranchId], [j1].[OneId] + SELECT [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [j1].[EntityBranchId], [j1].[EntityOneId] FROM [JoinOneToBranch] AS [j1] INNER JOIN ( SELECT [e2].[Id], [e2].[Discriminator], [e2].[Name], [e2].[Number], [e2].[IsGreen] FROM [EntityRoots] AS [e2] WHERE [e2].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t1] ON [j1].[BranchId] = [t1].[Id] + ) AS [t1] ON [j1].[EntityBranchId] = [t1].[Id] WHERE [t1].[Id] < 20 - ) AS [t2] ON [e0].[Id] = [t2].[OneId] + ) AS [t2] ON [e0].[Id] = [t2].[EntityOneId] WHERE [e0].[Id] < 10 ) AS [t3] ON [e].[Id] = [t3].[ThreeId] -ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1]"); +ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1]"); } public override async Task Filtered_include_on_skip_navigation_then_filtered_include_on_navigation(bool async) @@ -941,20 +941,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ await base.Filtered_include_on_navigation_then_filtered_include_on_skip_navigation(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0], [t0].[TwoId], [t0].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0], [t].[TwoId], [t].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0], [t].[ThreeId], [t].[TwoId] FROM [EntityTwos] AS [e0] LEFT JOIN ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 ) AS [t] ON [e0].[Id] = [t].[TwoId] WHERE [e0].[Id] > 15 ) AS [t0] ON [e].[Id] = [t0].[CollectionInverseId] -ORDER BY [e].[Id], [t0].[Id], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0]"); +ORDER BY [e].[Id], [t0].[Id], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0]"); } public override async Task Includes_accessed_via_different_path_are_merged(bool async) @@ -1044,10 +1044,10 @@ FROM [EntityRoots] AS [e0] ) AS [t] ON [j].[LeafId] = [t].[Id] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e1].[Id], [e1].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e1].[Id], [e1].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e1] ON [j0].[OneId] = [e1].[Id] -) AS [t1] ON [t0].[Id] = [t1].[BranchId] + INNER JOIN [EntityOnes] AS [e1] ON [j0].[EntityOneId] = [e1].[Id] +) AS [t1] ON [t0].[Id] = [t1].[EntityBranchId] ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]"); } @@ -1139,9 +1139,9 @@ FROM [EntityThrees] AS [e] @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -1362,7 +1362,7 @@ FROM [JoinOneToTwo] AS [j] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e].[Id] = [t0].[OneId] INNER JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 @@ -1398,9 +1398,9 @@ FROM [JoinOneToTwo] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] INNER JOIN ( - SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] + SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t0] @@ -1489,15 +1489,15 @@ FROM [JoinOneToThreePayloadFull] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[ThreeId] INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] FROM [JoinOneToBranch] AS [j0] INNER JOIN ( SELECT [e1].[Id], [e1].[Discriminator], [e1].[Name], [e1].[Number], [e1].[IsGreen] FROM [EntityRoots] AS [e1] WHERE [e1].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t0] ON [j0].[BranchId] = [t0].[Id] + ) AS [t0] ON [j0].[EntityBranchId] = [t0].[Id] WHERE [t0].[Id] < 20 -) AS [t1] ON [t].[Id] = [t1].[OneId] +) AS [t1] ON [t].[Id] = [t1].[EntityOneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]"); } @@ -1562,7 +1562,7 @@ FROM [EntityTwos] AS [e0] WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] INNER JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs index 9a8989a3116..f724e532811 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs @@ -102,8 +102,8 @@ INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t] ON [j].[BranchId] = [t].[Id] - WHERE ([e].[Id] = [j].[OneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] + WHERE ([e].[Id] = [j].[EntityOneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); } public override async Task Skip_navigation_long_count_without_predicate(bool async) @@ -289,14 +289,14 @@ public override async Task Skip_navigation_order_by_last_or_default(bool async) @"SELECT [t0].[Id], [t0].[Name] FROM [EntityRoots] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[Name], [t].[BranchId], [t].[OneId] + SELECT [t].[Id], [t].[Name], [t].[EntityBranchId], [t].[EntityOneId] FROM ( - SELECT [e0].[Id], [e0].[Name], [j].[BranchId], [j].[OneId], ROW_NUMBER() OVER(PARTITION BY [j].[BranchId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[Name], [j].[EntityBranchId], [j].[EntityOneId], ROW_NUMBER() OVER(PARTITION BY [j].[EntityBranchId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinOneToBranch] AS [j] - INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] + INNER JOIN [EntityOnes] AS [e0] ON [j].[EntityOneId] = [e0].[Id] ) AS [t] WHERE [t].[row] <= 1 -) AS [t0] ON [e].[Id] = [t0].[BranchId] +) AS [t0] ON [e].[Id] = [t0].[EntityBranchId] WHERE [e].[Discriminator] IN (N'EntityBranch', N'EntityLeaf')"); } @@ -308,9 +308,9 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -494,14 +494,14 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) @"SELECT [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] FROM [EntityOnes] AS [e] INNER JOIN ( - SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[BranchId], [j].[OneId] + SELECT [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [j].[EntityBranchId], [j].[EntityOneId] FROM [JoinOneToBranch] AS [j] INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t] ON [j].[BranchId] = [t].[Id] -) AS [t0] ON [e].[Id] = [t0].[OneId]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] +) AS [t0] ON [e].[Id] = [t0].[EntityOneId]"); } public override async Task Select_skip_navigation(bool async) @@ -524,10 +524,10 @@ public override async Task Select_skip_navigation_multiple(bool async) await base.Select_skip_navigation_multiple(async); AssertSql( - @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] + @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] FROM [EntityTwos] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e0] ON [j].[ThreeId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[TwoId] @@ -541,7 +541,7 @@ LEFT JOIN ( FROM [JoinTwoToCompositeKeyShared] AS [j1] INNER JOIN [EntityCompositeKeys] AS [e2] ON (([j1].[CompositeId1] = [e2].[Key1]) AND ([j1].[CompositeId2] = [e2].[Key2])) AND ([j1].[CompositeId3] = [e2].[Key3]) ) AS [t1] ON [e].[Id] = [t1].[TwoId] -ORDER BY [e].[Id], [t].[TwoId], [t].[ThreeId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); +ORDER BY [e].[Id], [t].[ThreeId], [t].[TwoId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); } public override async Task Select_skip_navigation_first_or_default(bool async) @@ -599,10 +599,10 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( await base.Include_skip_navigation_then_include_skip_navigation(async); AssertSql( - @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[BranchId], [t1].[OneId], [t1].[Id0], [t1].[Name0] + @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0], [t1].[Name0] FROM [EntityCompositeKeys] AS [e] LEFT JOIN ( - SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [t0].[BranchId], [t0].[OneId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0] + SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen], [t0].[EntityBranchId], [t0].[EntityOneId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0] FROM [JoinCompositeKeyToLeaf] AS [j] INNER JOIN ( SELECT [e0].[Id], [e0].[Discriminator], [e0].[Name], [e0].[Number], [e0].[IsGreen] @@ -610,12 +610,12 @@ FROM [EntityRoots] AS [e0] WHERE [e0].[Discriminator] = N'EntityLeaf' ) AS [t] ON [j].[LeafId] = [t].[Id] LEFT JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e1].[Id], [e1].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e1].[Id], [e1].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e1] ON [j0].[OneId] = [e1].[Id] - ) AS [t0] ON [t].[Id] = [t0].[BranchId] + INNER JOIN [EntityOnes] AS [e1] ON [j0].[EntityOneId] = [e1].[Id] + ) AS [t0] ON [t].[Id] = [t0].[EntityBranchId] ) AS [t1] ON (([e].[Key1] = [t1].[CompositeId1]) AND ([e].[Key2] = [t1].[CompositeId2])) AND ([e].[Key3] = [t1].[CompositeId3]) -ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[BranchId], [t1].[OneId], [t1].[Id0]"); +ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0]"); } public override async Task Include_skip_navigation_then_include_reference_and_skip_navigation(bool async) @@ -676,14 +676,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) await base.Filtered_include_skip_navigation_order_by(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[ThreeId] -ORDER BY [e].[Id], [t].[Id], [t].[TwoId], [t].[ThreeId]"); +ORDER BY [e].[Id], [t].[Id], [t].[ThreeId], [t].[TwoId]"); } public override async Task Filtered_include_skip_navigation_order_by_skip(bool async) @@ -815,10 +815,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t await base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] FROM [EntityOnes] AS [e] OUTER APPLY ( - SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] FROM ( SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] FROM [JoinOneToTwo] AS [j] @@ -828,13 +828,13 @@ ORDER BY [e0].[Id] OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY ) AS [t] LEFT JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 ) AS [t0] ON [t].[Id] = [t0].[TwoId] ) AS [t1] -ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0]"); +ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0]"); } public override async Task Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(bool async) @@ -842,16 +842,16 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s await base.Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] FROM [JoinOneToTwo] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] LEFT JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t] @@ -885,10 +885,10 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte await base.Filter_include_on_skip_navigation_combined_with_filtered_then_includes(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[OneId], [t3].[ThreeId], [t3].[Payload], [t3].[Id], [t3].[Name], [t3].[OneId0], [t3].[TwoId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1], [t3].[Discriminator], [t3].[Name1], [t3].[Number], [t3].[IsGreen] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[OneId], [t3].[ThreeId], [t3].[Payload], [t3].[Id], [t3].[Name], [t3].[OneId0], [t3].[TwoId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1], [t3].[Discriminator], [t3].[Name1], [t3].[Number], [t3].[IsGreen] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t2].[BranchId], [t2].[OneId] AS [OneId1], [t2].[Id] AS [Id1], [t2].[Discriminator], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen] + SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t2].[EntityBranchId], [t2].[EntityOneId], [t2].[Id] AS [Id1], [t2].[Discriminator], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen] FROM [JoinOneToThreePayloadFull] AS [j] INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] LEFT JOIN ( @@ -901,18 +901,18 @@ FROM [JoinOneToTwo] AS [j0] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e0].[Id] = [t0].[OneId] LEFT JOIN ( - SELECT [j1].[BranchId], [j1].[OneId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen] + SELECT [j1].[EntityBranchId], [j1].[EntityOneId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen] FROM [JoinOneToBranch] AS [j1] INNER JOIN ( SELECT [e2].[Id], [e2].[Discriminator], [e2].[Name], [e2].[Number], [e2].[IsGreen] FROM [EntityRoots] AS [e2] WHERE [e2].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t1] ON [j1].[BranchId] = [t1].[Id] + ) AS [t1] ON [j1].[EntityBranchId] = [t1].[Id] WHERE [t1].[Id] < 20 - ) AS [t2] ON [e0].[Id] = [t2].[OneId] + ) AS [t2] ON [e0].[Id] = [t2].[EntityOneId] WHERE [e0].[Id] < 10 ) AS [t3] ON [e].[Id] = [t3].[ThreeId] -ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1]"); +ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1]"); } public override async Task Filtered_include_on_skip_navigation_then_filtered_include_on_navigation(bool async) @@ -941,20 +941,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ await base.Filtered_include_on_navigation_then_filtered_include_on_skip_navigation(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0] FROM [EntityTwos] AS [e0] LEFT JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 ) AS [t] ON [e0].[Id] = [t].[TwoId] WHERE [e0].[Id] > 15 ) AS [t0] ON [e].[Id] = [t0].[CollectionInverseId] -ORDER BY [e].[Id], [t0].[Id], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0]"); +ORDER BY [e].[Id], [t0].[Id], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0]"); } public override async Task Includes_accessed_via_different_path_are_merged(bool async) @@ -1032,7 +1032,7 @@ FROM [EntityRoots] AS [e0] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]", // - @"SELECT [t1].[BranchId], [t1].[OneId], [t1].[Id], [t1].[Name], [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id] + @"SELECT [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id], [t1].[Name], [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id] FROM [EntityCompositeKeys] AS [e] INNER JOIN ( SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Discriminator], [t].[Name], [t].[Number], [t].[IsGreen] @@ -1044,10 +1044,10 @@ FROM [EntityRoots] AS [e0] ) AS [t] ON [j].[LeafId] = [t].[Id] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e1].[Id], [e1].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e1].[Id], [e1].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e1] ON [j0].[OneId] = [e1].[Id] -) AS [t1] ON [t0].[Id] = [t1].[BranchId] + INNER JOIN [EntityOnes] AS [e1] ON [j0].[EntityOneId] = [e1].[Id] +) AS [t1] ON [t0].[Id] = [t1].[EntityBranchId] ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]"); } @@ -1136,12 +1136,12 @@ public override async Task Filtered_include_skip_navigation_order_by_split(bool FROM [EntityThrees] AS [e] ORDER BY [e].[Id]", // - @"SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] + @"SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -1350,7 +1350,7 @@ FROM [JoinOneToTwo] AS [j] ) AS [t0] ON [e].[Id] = [t0].[OneId] ORDER BY [e].[Id], [t0].[OneId], [t0].[Id], [t0].[TwoId]", // - @"SELECT [t1].[TwoId], [t1].[ThreeId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t0].[OneId], [t0].[TwoId], [t0].[Id] + @"SELECT [t1].[ThreeId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t0].[OneId], [t0].[TwoId], [t0].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] @@ -1362,7 +1362,7 @@ FROM [JoinOneToTwo] AS [j] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e].[Id] = [t0].[OneId] INNER JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 @@ -1389,7 +1389,7 @@ WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] ORDER BY [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id]", // - @"SELECT [t1].[TwoId], [t1].[ThreeId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id] + @"SELECT [t1].[ThreeId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] @@ -1398,9 +1398,9 @@ FROM [JoinOneToTwo] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] INNER JOIN ( - SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] + SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t0] @@ -1480,7 +1480,7 @@ FROM [JoinOneToTwo] AS [j0] ) AS [t1] ON [t].[Id] = [t1].[OneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id], [t1].[OneId], [t1].[Id]", // - @"SELECT [t1].[BranchId], [t1].[OneId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id] + @"SELECT [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id], [t1].[Discriminator], [t1].[Name], [t1].[Number], [t1].[IsGreen], [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name] @@ -1489,15 +1489,15 @@ FROM [JoinOneToThreePayloadFull] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[ThreeId] INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [t0].[Id], [t0].[Discriminator], [t0].[Name], [t0].[Number], [t0].[IsGreen] FROM [JoinOneToBranch] AS [j0] INNER JOIN ( SELECT [e1].[Id], [e1].[Discriminator], [e1].[Name], [e1].[Number], [e1].[IsGreen] FROM [EntityRoots] AS [e1] WHERE [e1].[Discriminator] IN (N'EntityBranch', N'EntityLeaf') - ) AS [t0] ON [j0].[BranchId] = [t0].[Id] + ) AS [t0] ON [j0].[EntityBranchId] = [t0].[Id] WHERE [t0].[Id] < 20 -) AS [t1] ON [t].[Id] = [t1].[OneId] +) AS [t1] ON [t].[Id] = [t1].[EntityOneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]"); } @@ -1554,7 +1554,7 @@ WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] ORDER BY [e].[Id], [t].[Id]", // - @"SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id], [t].[Id] + @"SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id], [t].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] @@ -1562,7 +1562,7 @@ FROM [EntityTwos] AS [e0] WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] INNER JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs index b0258576957..9d4e3b36c53 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs @@ -104,8 +104,8 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t] ON [j].[BranchId] = [t].[Id] - WHERE ([e].[Id] = [j].[OneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] + WHERE ([e].[Id] = [j].[EntityOneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); } public override async Task Skip_navigation_long_count_without_predicate(bool async) @@ -304,14 +304,14 @@ FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] LEFT JOIN ( - SELECT [t].[Id], [t].[Name], [t].[BranchId], [t].[OneId] + SELECT [t].[Id], [t].[Name], [t].[EntityBranchId], [t].[EntityOneId] FROM ( - SELECT [e].[Id], [e].[Name], [j].[BranchId], [j].[OneId], ROW_NUMBER() OVER(PARTITION BY [j].[BranchId] ORDER BY [e].[Id] DESC) AS [row] + SELECT [e].[Id], [e].[Name], [j].[EntityBranchId], [j].[EntityOneId], ROW_NUMBER() OVER(PARTITION BY [j].[EntityBranchId] ORDER BY [e].[Id] DESC) AS [row] FROM [JoinOneToBranch] AS [j] - INNER JOIN [EntityOnes] AS [e] ON [j].[OneId] = [e].[Id] + INNER JOIN [EntityOnes] AS [e] ON [j].[EntityOneId] = [e].[Id] ) AS [t] WHERE [t].[row] <= 1 -) AS [t0] ON [r].[Id] = [t0].[BranchId]"); +) AS [t0] ON [r].[Id] = [t0].[EntityBranchId]"); } public override async Task Skip_navigation_order_by_reverse_first_or_default(bool async) @@ -322,9 +322,9 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -527,7 +527,7 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) @"SELECT [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] FROM [EntityOnes] AS [e] INNER JOIN ( - SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t].[Discriminator], [j].[BranchId], [j].[OneId] + SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t].[Discriminator], [j].[EntityBranchId], [j].[EntityOneId] FROM [JoinOneToBranch] AS [j] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -536,8 +536,8 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t] ON [j].[BranchId] = [t].[Id] -) AS [t0] ON [e].[Id] = [t0].[OneId]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] +) AS [t0] ON [e].[Id] = [t0].[EntityOneId]"); } public override async Task Select_skip_navigation(bool async) @@ -560,10 +560,10 @@ public override async Task Select_skip_navigation_multiple(bool async) await base.Select_skip_navigation_multiple(async); AssertSql( - @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] + @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] FROM [EntityTwos] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e0] ON [j].[ThreeId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[TwoId] @@ -577,7 +577,7 @@ LEFT JOIN ( FROM [JoinTwoToCompositeKeyShared] AS [j1] INNER JOIN [EntityCompositeKeys] AS [e2] ON (([j1].[CompositeId1] = [e2].[Key1]) AND ([j1].[CompositeId2] = [e2].[Key2])) AND ([j1].[CompositeId3] = [e2].[Key3]) ) AS [t1] ON [e].[Id] = [t1].[TwoId] -ORDER BY [e].[Id], [t].[TwoId], [t].[ThreeId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); +ORDER BY [e].[Id], [t].[ThreeId], [t].[TwoId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); } public override async Task Select_skip_navigation_first_or_default(bool async) @@ -643,10 +643,10 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( await base.Include_skip_navigation_then_include_skip_navigation(async); AssertSql( - @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id0], [t1].[Name0], [t1].[BranchId], [t1].[OneId] + @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id0], [t1].[Name0], [t1].[EntityBranchId], [t1].[EntityOneId] FROM [EntityCompositeKeys] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0], [t0].[BranchId], [t0].[OneId] + SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0], [t0].[EntityBranchId], [t0].[EntityOneId] FROM [JoinCompositeKeyToLeaf] AS [j] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen] @@ -655,12 +655,12 @@ FROM [Roots] AS [r] INNER JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] ) AS [t] ON [j].[LeafId] = [t].[Id] LEFT JOIN ( - SELECT [e0].[Id], [e0].[Name], [j0].[BranchId], [j0].[OneId] + SELECT [e0].[Id], [e0].[Name], [j0].[EntityBranchId], [j0].[EntityOneId] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e0] ON [j0].[OneId] = [e0].[Id] - ) AS [t0] ON [t].[Id] = [t0].[BranchId] + INNER JOIN [EntityOnes] AS [e0] ON [j0].[EntityOneId] = [e0].[Id] + ) AS [t0] ON [t].[Id] = [t0].[EntityBranchId] ) AS [t1] ON (([e].[Key1] = [t1].[CompositeId1]) AND ([e].[Key2] = [t1].[CompositeId2])) AND ([e].[Key3] = [t1].[CompositeId3]) -ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[BranchId], [t1].[OneId], [t1].[Id0]"); +ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0]"); } public override async Task Include_skip_navigation_then_include_reference_and_skip_navigation(bool async) @@ -721,14 +721,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) await base.Filtered_include_skip_navigation_order_by(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[ThreeId] -ORDER BY [e].[Id], [t].[Id], [t].[TwoId], [t].[ThreeId]"); +ORDER BY [e].[Id], [t].[Id], [t].[ThreeId], [t].[TwoId]"); } public override async Task Filtered_include_skip_navigation_order_by_skip(bool async) @@ -871,10 +871,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t await base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[TwoId0], [t1].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[ThreeId], [t1].[TwoId0] FROM [EntityOnes] AS [e] OUTER APPLY ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[OneId], [t].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[OneId], [t].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0] FROM ( SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId] FROM [JoinOneToTwo] AS [j] @@ -884,13 +884,13 @@ ORDER BY [e0].[Id] OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY ) AS [t] LEFT JOIN ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[TwoId], [j0].[ThreeId] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[ThreeId], [j0].[TwoId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 ) AS [t0] ON [t].[Id] = [t0].[TwoId] ) AS [t1] -ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0]"); +ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0]"); } public override async Task Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(bool async) @@ -898,16 +898,16 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s await base.Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[TwoId0], [t1].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[OneId], [t1].[TwoId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0], [t1].[ThreeId], [t1].[TwoId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[OneId], [j].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0] FROM [JoinOneToTwo] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[TwoId], [j0].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j0].[ThreeId], [j0].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t] @@ -941,10 +941,10 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte await base.Filter_include_on_skip_navigation_combined_with_filtered_then_includes(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[Id], [t3].[Name], [t3].[OneId], [t3].[ThreeId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[OneId0], [t3].[TwoId], [t3].[Id1], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[Discriminator], [t3].[BranchId], [t3].[OneId1] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[Id], [t3].[Name], [t3].[OneId], [t3].[ThreeId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[OneId0], [t3].[TwoId], [t3].[Id1], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[Discriminator], [t3].[EntityBranchId], [t3].[EntityOneId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[Name], [j].[OneId], [j].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t2].[Id] AS [Id1], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[Discriminator], [t2].[BranchId], [t2].[OneId] AS [OneId1] + SELECT [e0].[Id], [e0].[Name], [j].[OneId], [j].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t2].[Id] AS [Id1], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[Discriminator], [t2].[EntityBranchId], [t2].[EntityOneId] FROM [JoinOneToThreePayloadFull] AS [j] INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] LEFT JOIN ( @@ -957,7 +957,7 @@ FROM [JoinOneToTwo] AS [j0] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e0].[Id] = [t0].[OneId] LEFT JOIN ( - SELECT [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator], [j1].[BranchId], [j1].[OneId] + SELECT [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator], [j1].[EntityBranchId], [j1].[EntityOneId] FROM [JoinOneToBranch] AS [j1] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -966,12 +966,12 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t1] ON [j1].[BranchId] = [t1].[Id] + ) AS [t1] ON [j1].[EntityBranchId] = [t1].[Id] WHERE [t1].[Id] < 20 - ) AS [t2] ON [e0].[Id] = [t2].[OneId] + ) AS [t2] ON [e0].[Id] = [t2].[EntityOneId] WHERE [e0].[Id] < 10 ) AS [t3] ON [e].[Id] = [t3].[ThreeId] -ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1]"); +ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1]"); } public override async Task Filtered_include_on_skip_navigation_then_filtered_include_on_navigation(bool async) @@ -1000,20 +1000,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ await base.Filtered_include_on_navigation_then_filtered_include_on_skip_navigation(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0], [t0].[TwoId], [t0].[ThreeId] + @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0], [t0].[ThreeId], [t0].[TwoId] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0], [t].[TwoId], [t].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0], [t].[ThreeId], [t].[TwoId] FROM [EntityTwos] AS [e0] LEFT JOIN ( - SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 ) AS [t] ON [e0].[Id] = [t].[TwoId] WHERE [e0].[Id] > 15 ) AS [t0] ON [e].[Id] = [t0].[CollectionInverseId] -ORDER BY [e].[Id], [t0].[Id], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0]"); +ORDER BY [e].[Id], [t0].[Id], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0]"); } public override async Task Includes_accessed_via_different_path_are_merged(bool async) @@ -1113,10 +1113,10 @@ FROM [Roots] AS [r] ) AS [t] ON [j].[LeafId] = [t].[Id] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e0].[Id], [e0].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e0].[Id], [e0].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e0] ON [j0].[OneId] = [e0].[Id] -) AS [t1] ON [t0].[Id] = [t1].[BranchId] + INNER JOIN [EntityOnes] AS [e0] ON [j0].[EntityOneId] = [e0].[Id] +) AS [t1] ON [t0].[Id] = [t1].[EntityBranchId] ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]"); } @@ -1208,9 +1208,9 @@ FROM [EntityThrees] AS [e] @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -1452,7 +1452,7 @@ FROM [JoinOneToTwo] AS [j] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e].[Id] = [t0].[OneId] INNER JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 @@ -1488,9 +1488,9 @@ FROM [JoinOneToTwo] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] INNER JOIN ( - SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] + SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t0] @@ -1579,7 +1579,7 @@ FROM [JoinOneToThreePayloadFull] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[ThreeId] INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] FROM [JoinOneToBranch] AS [j0] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -1588,9 +1588,9 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t0] ON [j0].[BranchId] = [t0].[Id] + ) AS [t0] ON [j0].[EntityBranchId] = [t0].[Id] WHERE [t0].[Id] < 20 -) AS [t1] ON [t].[Id] = [t1].[OneId] +) AS [t1] ON [t].[Id] = [t1].[EntityOneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]"); } @@ -1655,7 +1655,7 @@ FROM [EntityTwos] AS [e0] WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] INNER JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs index 808f1c34cde..a84ddf19eb1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs @@ -104,8 +104,8 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t] ON [j].[BranchId] = [t].[Id] - WHERE ([e].[Id] = [j].[OneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] + WHERE ([e].[Id] = [j].[EntityOneId]) AND ([t].[Name] IS NOT NULL AND ([t].[Name] LIKE N'L%'))), [e].[Id]"); } public override async Task Skip_navigation_long_count_without_predicate(bool async) @@ -304,14 +304,14 @@ FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] LEFT JOIN ( - SELECT [t].[Id], [t].[Name], [t].[BranchId], [t].[OneId] + SELECT [t].[Id], [t].[Name], [t].[EntityBranchId], [t].[EntityOneId] FROM ( - SELECT [e].[Id], [e].[Name], [j].[BranchId], [j].[OneId], ROW_NUMBER() OVER(PARTITION BY [j].[BranchId] ORDER BY [e].[Id] DESC) AS [row] + SELECT [e].[Id], [e].[Name], [j].[EntityBranchId], [j].[EntityOneId], ROW_NUMBER() OVER(PARTITION BY [j].[EntityBranchId] ORDER BY [e].[Id] DESC) AS [row] FROM [JoinOneToBranch] AS [j] - INNER JOIN [EntityOnes] AS [e] ON [j].[OneId] = [e].[Id] + INNER JOIN [EntityOnes] AS [e] ON [j].[EntityOneId] = [e].[Id] ) AS [t] WHERE [t].[row] <= 1 -) AS [t0] ON [r].[Id] = [t0].[BranchId]"); +) AS [t0] ON [r].[Id] = [t0].[EntityBranchId]"); } public override async Task Skip_navigation_order_by_reverse_first_or_default(bool async) @@ -322,9 +322,9 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo @"SELECT [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId] + SELECT [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId] FROM ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id] DESC) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -527,7 +527,7 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) @"SELECT [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] FROM [EntityOnes] AS [e] INNER JOIN ( - SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t].[Discriminator], [j].[BranchId], [j].[OneId] + SELECT [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t].[Discriminator], [j].[EntityBranchId], [j].[EntityOneId] FROM [JoinOneToBranch] AS [j] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -536,8 +536,8 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t] ON [j].[BranchId] = [t].[Id] -) AS [t0] ON [e].[Id] = [t0].[OneId]"); + ) AS [t] ON [j].[EntityBranchId] = [t].[Id] +) AS [t0] ON [e].[Id] = [t0].[EntityOneId]"); } public override async Task Select_skip_navigation(bool async) @@ -560,10 +560,10 @@ public override async Task Select_skip_navigation_multiple(bool async) await base.Select_skip_navigation_multiple(async); AssertSql( - @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] + @"SELECT [e].[Id], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[LeftId], [t0].[RightId], [t1].[Key1], [t1].[Key2], [t1].[Key3], [t1].[Name], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3] FROM [EntityTwos] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[TwoId], [j].[ThreeId] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [j].[ThreeId], [j].[TwoId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e0] ON [j].[ThreeId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[TwoId] @@ -577,7 +577,7 @@ LEFT JOIN ( FROM [JoinTwoToCompositeKeyShared] AS [j1] INNER JOIN [EntityCompositeKeys] AS [e2] ON (([j1].[CompositeId1] = [e2].[Key1]) AND ([j1].[CompositeId2] = [e2].[Key2])) AND ([j1].[CompositeId3] = [e2].[Key3]) ) AS [t1] ON [e].[Id] = [t1].[TwoId] -ORDER BY [e].[Id], [t].[TwoId], [t].[ThreeId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); +ORDER BY [e].[Id], [t].[ThreeId], [t].[TwoId], [t].[Id], [t0].[LeftId], [t0].[RightId], [t0].[Id], [t1].[TwoId], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[Key1], [t1].[Key2], [t1].[Key3]"); } public override async Task Select_skip_navigation_first_or_default(bool async) @@ -643,10 +643,10 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( await base.Include_skip_navigation_then_include_skip_navigation(async); AssertSql( - @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[BranchId], [t1].[OneId], [t1].[Id0], [t1].[Name0] + @"SELECT [e].[Key1], [e].[Key2], [e].[Key3], [e].[Name], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0], [t1].[Name0] FROM [EntityCompositeKeys] AS [e] LEFT JOIN ( - SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t0].[BranchId], [t0].[OneId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0] + SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen], [t0].[EntityBranchId], [t0].[EntityOneId], [t0].[Id] AS [Id0], [t0].[Name] AS [Name0] FROM [JoinCompositeKeyToLeaf] AS [j] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen] @@ -655,12 +655,12 @@ FROM [Roots] AS [r] INNER JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] ) AS [t] ON [j].[LeafId] = [t].[Id] LEFT JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e0].[Id], [e0].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e0].[Id], [e0].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e0] ON [j0].[OneId] = [e0].[Id] - ) AS [t0] ON [t].[Id] = [t0].[BranchId] + INNER JOIN [EntityOnes] AS [e0] ON [j0].[EntityOneId] = [e0].[Id] + ) AS [t0] ON [t].[Id] = [t0].[EntityBranchId] ) AS [t1] ON (([e].[Key1] = [t1].[CompositeId1]) AND ([e].[Key2] = [t1].[CompositeId2])) AND ([e].[Key3] = [t1].[CompositeId3]) -ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[BranchId], [t1].[OneId], [t1].[Id0]"); +ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t1].[CompositeId1], [t1].[CompositeId2], [t1].[CompositeId3], [t1].[LeafId], [t1].[Id], [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id0]"); } public override async Task Include_skip_navigation_then_include_reference_and_skip_navigation(bool async) @@ -721,14 +721,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) await base.Filtered_include_skip_navigation_order_by(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] ON [e].[Id] = [t].[ThreeId] -ORDER BY [e].[Id], [t].[Id], [t].[TwoId], [t].[ThreeId]"); +ORDER BY [e].[Id], [t].[Id], [t].[ThreeId], [t].[TwoId]"); } public override async Task Filtered_include_skip_navigation_order_by_skip(bool async) @@ -871,10 +871,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t await base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] FROM [EntityOnes] AS [e] OUTER APPLY ( - SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] FROM ( SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] FROM [JoinOneToTwo] AS [j] @@ -884,13 +884,13 @@ ORDER BY [e0].[Id] OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY ) AS [t] LEFT JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 ) AS [t0] ON [t].[Id] = [t0].[TwoId] ) AS [t1] -ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0]"); +ORDER BY [e].[Id], [t1].[Id], [t1].[OneId], [t1].[TwoId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0]"); } public override async Task Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(bool async) @@ -898,16 +898,16 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s await base.Filtered_include_skip_navigation_where_then_include_skip_navigation_order_by_skip_take(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[TwoId0], [t1].[ThreeId], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t1].[OneId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [t1].[ThreeId], [t1].[TwoId0], [t1].[Id0], [t1].[CollectionInverseId0], [t1].[Name0], [t1].[ReferenceInverseId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t0].[TwoId] AS [TwoId0], [t0].[ThreeId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId] AS [TwoId0], [t0].[Id] AS [Id0], [t0].[CollectionInverseId] AS [CollectionInverseId0], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId] AS [ReferenceInverseId0] FROM [JoinOneToTwo] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] LEFT JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t] @@ -941,10 +941,10 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte await base.Filter_include_on_skip_navigation_combined_with_filtered_then_includes(async); AssertSql( - @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[OneId], [t3].[ThreeId], [t3].[Payload], [t3].[Id], [t3].[Name], [t3].[OneId0], [t3].[TwoId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[Discriminator] + @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t3].[OneId], [t3].[ThreeId], [t3].[Payload], [t3].[Id], [t3].[Name], [t3].[OneId0], [t3].[TwoId], [t3].[Id0], [t3].[CollectionInverseId], [t3].[Name0], [t3].[ReferenceInverseId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1], [t3].[Name1], [t3].[Number], [t3].[IsGreen], [t3].[Discriminator] FROM [EntityThrees] AS [e] LEFT JOIN ( - SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t2].[BranchId], [t2].[OneId] AS [OneId1], [t2].[Id] AS [Id1], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[Discriminator] + SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name], [t0].[OneId] AS [OneId0], [t0].[TwoId], [t0].[Id] AS [Id0], [t0].[CollectionInverseId], [t0].[Name] AS [Name0], [t0].[ReferenceInverseId], [t2].[EntityBranchId], [t2].[EntityOneId], [t2].[Id] AS [Id1], [t2].[Name] AS [Name1], [t2].[Number], [t2].[IsGreen], [t2].[Discriminator] FROM [JoinOneToThreePayloadFull] AS [j] INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id] LEFT JOIN ( @@ -957,7 +957,7 @@ FROM [JoinOneToTwo] AS [j0] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e0].[Id] = [t0].[OneId] LEFT JOIN ( - SELECT [j1].[BranchId], [j1].[OneId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator] + SELECT [j1].[EntityBranchId], [j1].[EntityOneId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator] FROM [JoinOneToBranch] AS [j1] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -966,12 +966,12 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t1] ON [j1].[BranchId] = [t1].[Id] + ) AS [t1] ON [j1].[EntityBranchId] = [t1].[Id] WHERE [t1].[Id] < 20 - ) AS [t2] ON [e0].[Id] = [t2].[OneId] + ) AS [t2] ON [e0].[Id] = [t2].[EntityOneId] WHERE [e0].[Id] < 10 ) AS [t3] ON [e].[Id] = [t3].[ThreeId] -ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[BranchId], [t3].[OneId1], [t3].[Id1]"); +ORDER BY [e].[Id], [t3].[OneId], [t3].[ThreeId], [t3].[Id], [t3].[OneId0], [t3].[Id0], [t3].[TwoId], [t3].[EntityBranchId], [t3].[EntityOneId], [t3].[Id1]"); } public override async Task Filtered_include_on_skip_navigation_then_filtered_include_on_navigation(bool async) @@ -1000,20 +1000,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ await base.Filtered_include_on_navigation_then_filtered_include_on_skip_navigation(async); AssertSql( - @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0] + @"SELECT [e].[Id], [e].[Name], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0], [t0].[CollectionInverseId0], [t0].[Name0], [t0].[ReferenceInverseId0] FROM [EntityOnes] AS [e] LEFT JOIN ( - SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[TwoId], [t].[ThreeId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0] + SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], [t].[ThreeId], [t].[TwoId], [t].[Id] AS [Id0], [t].[CollectionInverseId] AS [CollectionInverseId0], [t].[Name] AS [Name0], [t].[ReferenceInverseId] AS [ReferenceInverseId0] FROM [EntityTwos] AS [e0] LEFT JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 ) AS [t] ON [e0].[Id] = [t].[TwoId] WHERE [e0].[Id] > 15 ) AS [t0] ON [e].[Id] = [t0].[CollectionInverseId] -ORDER BY [e].[Id], [t0].[Id], [t0].[TwoId], [t0].[ThreeId], [t0].[Id0]"); +ORDER BY [e].[Id], [t0].[Id], [t0].[ThreeId], [t0].[TwoId], [t0].[Id0]"); } public override async Task Includes_accessed_via_different_path_are_merged(bool async) @@ -1100,7 +1100,7 @@ FROM [Roots] AS [r] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]", // - @"SELECT [t1].[BranchId], [t1].[OneId], [t1].[Id], [t1].[Name], [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id] + @"SELECT [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id], [t1].[Name], [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id] FROM [EntityCompositeKeys] AS [e] INNER JOIN ( SELECT [j].[CompositeId1], [j].[CompositeId2], [j].[CompositeId3], [j].[LeafId], [t].[Id], [t].[Name], [t].[Number], [t].[IsGreen] @@ -1113,10 +1113,10 @@ FROM [Roots] AS [r] ) AS [t] ON [j].[LeafId] = [t].[Id] ) AS [t0] ON (([e].[Key1] = [t0].[CompositeId1]) AND ([e].[Key2] = [t0].[CompositeId2])) AND ([e].[Key3] = [t0].[CompositeId3]) INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [e0].[Id], [e0].[Name] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [e0].[Id], [e0].[Name] FROM [JoinOneToBranch] AS [j0] - INNER JOIN [EntityOnes] AS [e0] ON [j0].[OneId] = [e0].[Id] -) AS [t1] ON [t0].[Id] = [t1].[BranchId] + INNER JOIN [EntityOnes] AS [e0] ON [j0].[EntityOneId] = [e0].[Id] +) AS [t1] ON [t0].[Id] = [t1].[EntityBranchId] ORDER BY [e].[Key1], [e].[Key2], [e].[Key3], [t0].[CompositeId1], [t0].[CompositeId2], [t0].[CompositeId3], [t0].[LeafId], [t0].[Id]"); } @@ -1205,12 +1205,12 @@ public override async Task Filtered_include_skip_navigation_order_by_split(bool FROM [EntityThrees] AS [e] ORDER BY [e].[Id]", // - @"SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] + @"SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( - SELECT [t].[TwoId], [t].[ThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] + SELECT [t].[ThreeId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] FROM ( - SELECT [j].[TwoId], [j].[ThreeId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] + SELECT [j].[ThreeId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j].[ThreeId] ORDER BY [e0].[Id]) AS [row] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityTwos] AS [e0] ON [j].[TwoId] = [e0].[Id] ) AS [t] @@ -1440,7 +1440,7 @@ FROM [JoinOneToTwo] AS [j] ) AS [t0] ON [e].[Id] = [t0].[OneId] ORDER BY [e].[Id], [t0].[OneId], [t0].[Id], [t0].[TwoId]", // - @"SELECT [t1].[TwoId], [t1].[ThreeId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t0].[OneId], [t0].[TwoId], [t0].[Id] + @"SELECT [t1].[ThreeId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t0].[OneId], [t0].[TwoId], [t0].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [t].[OneId], [t].[TwoId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId] @@ -1452,7 +1452,7 @@ FROM [JoinOneToTwo] AS [j] WHERE (1 < [t].[row]) AND ([t].[row] <= 3) ) AS [t0] ON [e].[Id] = [t0].[OneId] INNER JOIN ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 10 @@ -1479,7 +1479,7 @@ WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] ORDER BY [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id]", // - @"SELECT [t1].[TwoId], [t1].[ThreeId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id] + @"SELECT [t1].[ThreeId], [t1].[TwoId], [t1].[Id], [t1].[CollectionInverseId], [t1].[Name], [t1].[ReferenceInverseId], [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [j].[OneId], [j].[TwoId], [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] @@ -1488,9 +1488,9 @@ FROM [JoinOneToTwo] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[OneId] INNER JOIN ( - SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] + SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId] FROM ( - SELECT [j0].[TwoId], [j0].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] + SELECT [j0].[ThreeId], [j0].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], ROW_NUMBER() OVER(PARTITION BY [j0].[TwoId] ORDER BY [e1].[Id]) AS [row] FROM [JoinTwoToThree] AS [j0] INNER JOIN [EntityThrees] AS [e1] ON [j0].[ThreeId] = [e1].[Id] ) AS [t0] @@ -1570,7 +1570,7 @@ FROM [JoinOneToTwo] AS [j0] ) AS [t1] ON [t].[Id] = [t1].[OneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id], [t1].[OneId], [t1].[Id]", // - @"SELECT [t1].[BranchId], [t1].[OneId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator], [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id] + @"SELECT [t1].[EntityBranchId], [t1].[EntityOneId], [t1].[Id], [t1].[Name], [t1].[Number], [t1].[IsGreen], [t1].[Discriminator], [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id] FROM [EntityThrees] AS [e] INNER JOIN ( SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name] @@ -1579,7 +1579,7 @@ FROM [JoinOneToThreePayloadFull] AS [j] WHERE [e0].[Id] < 10 ) AS [t] ON [e].[Id] = [t].[ThreeId] INNER JOIN ( - SELECT [j0].[BranchId], [j0].[OneId], [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] + SELECT [j0].[EntityBranchId], [j0].[EntityOneId], [t0].[Id], [t0].[Name], [t0].[Number], [t0].[IsGreen], [t0].[Discriminator] FROM [JoinOneToBranch] AS [j0] INNER JOIN ( SELECT [r].[Id], [r].[Name], [b].[Number], [l].[IsGreen], CASE @@ -1588,9 +1588,9 @@ END AS [Discriminator] FROM [Roots] AS [r] INNER JOIN [Branches] AS [b] ON [r].[Id] = [b].[Id] LEFT JOIN [Leaves] AS [l] ON [r].[Id] = [l].[Id] - ) AS [t0] ON [j0].[BranchId] = [t0].[Id] + ) AS [t0] ON [j0].[EntityBranchId] = [t0].[Id] WHERE [t0].[Id] < 20 -) AS [t1] ON [t].[Id] = [t1].[OneId] +) AS [t1] ON [t].[Id] = [t1].[EntityOneId] ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]"); } @@ -1647,7 +1647,7 @@ WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] ORDER BY [e].[Id], [t].[Id]", // - @"SELECT [t0].[TwoId], [t0].[ThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id], [t].[Id] + @"SELECT [t0].[ThreeId], [t0].[TwoId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [e].[Id], [t].[Id] FROM [EntityOnes] AS [e] INNER JOIN ( SELECT [e0].[Id], [e0].[CollectionInverseId], [e0].[Name], [e0].[ReferenceInverseId] @@ -1655,7 +1655,7 @@ FROM [EntityTwos] AS [e0] WHERE [e0].[Id] > 15 ) AS [t] ON [e].[Id] = [t].[CollectionInverseId] INNER JOIN ( - SELECT [j].[TwoId], [j].[ThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] + SELECT [j].[ThreeId], [j].[TwoId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId] FROM [JoinTwoToThree] AS [j] INNER JOIN [EntityThrees] AS [e1] ON [j].[ThreeId] = [e1].[Id] WHERE [e1].[Id] < 5 diff --git a/test/EFCore.Tests/Metadata/Conventions/ManyToManyAssociationEntityTypeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs similarity index 100% rename from test/EFCore.Tests/Metadata/Conventions/ManyToManyAssociationEntityTypeConventionTest.cs rename to test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs diff --git a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs index 09066c49416..635bfbc714e 100644 --- a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs @@ -502,13 +502,24 @@ public virtual void Unconfigured_many_to_many_navigations_throw() { var modelBuilder = CreateModelBuilder(); - modelBuilder.Entity(); + modelBuilder.Entity(); Assert.Equal( - CoreStrings.NavigationNotAdded(typeof(AmbigiousManyToManyImplicitLeft).DisplayName(fullName: false), "Navigation1", - typeof(List).DisplayName(fullName: false)), + CoreStrings.NavigationNotAdded(typeof(AmbiguousManyToManyImplicitLeft).DisplayName(fullName: false), "Navigation1", + typeof(List).DisplayName(fullName: false)), Assert.Throws(() => modelBuilder.FinalizeModel()).Message); } + + [ConditionalFact(Skip = "Issue#21890")] + public virtual void Skip_navigation_with_conflicting_inverse_property_attributes_are_removed() + { + var modelBuilder = CreateModelBuilder(); + + modelBuilder.Entity(); + modelBuilder.Entity(); + + var model = modelBuilder.FinalizeModel(); + } } } } diff --git a/test/EFCore.Tests/ModelBuilding/TestModel.cs b/test/EFCore.Tests/ModelBuilding/TestModel.cs index fd5825f4861..f8aa69d708c 100644 --- a/test/EFCore.Tests/ModelBuilding/TestModel.cs +++ b/test/EFCore.Tests/ModelBuilding/TestModel.cs @@ -1115,18 +1115,42 @@ protected class CollectionNavigationToSharedType public List> Navigation { get; set; } } - protected class AmbigiousManyToManyImplicitLeft + protected class AmbiguousManyToManyImplicitLeft { public int Id { get; set; } - public List Navigation1 { get; } = new List(); - public List Navigation2 { get; } = new List(); + public List Navigation1 { get; } = new List(); + public List Navigation2 { get; } = new List(); } - protected class AmbigiousManyToManyImplicitRight + protected class AmbiguousManyToManyImplicitRight { public int Id { get; set; } - public List Navigation1 { get; } = new List(); - public List Navigation2 { get; } = new List(); + public List Navigation1 { get; } = new List(); + public List Navigation2 { get; } = new List(); + } + + protected class AmbiguousInversePropertyLeft + { + public int Id { get; set; } + public List BaseRights { get; set; } + } + + protected class AmbiguousInversePropertyLeftDerived : AmbiguousInversePropertyLeft + { + public List DerivedRights { get; set; } + } + + protected class AmbiguousInversePropertyRight + { + public int Id { get; set; } + [InverseProperty("BaseRights")] + public List BaseLefts { get; set; } + } + + protected class AmbiguousInversePropertyRightDerived : AmbiguousInversePropertyRight + { + [InverseProperty("BaseRights")] + public List DerivedLefts { get; set; } } } }