diff --git a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
index af0a260930d..0c2e11616ee 100644
--- a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
+++ b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs
@@ -121,8 +121,7 @@ protected virtual void GenerateEntityTypes(
Check.NotNull(stringBuilder, nameof(stringBuilder));
foreach (var entityType in entityTypes.Where(
- e => !e.HasDefiningNavigation()
- && e.FindOwnership() == null))
+ e => e.FindOwnership() == null))
{
stringBuilder.AppendLine();
@@ -130,8 +129,7 @@ protected virtual void GenerateEntityTypes(
}
foreach (var entityType in entityTypes.Where(
- e => !e.HasDefiningNavigation()
- && e.FindOwnership() == null
+ e => e.FindOwnership() == null
&& (e.GetDeclaredForeignKeys().Any()
|| e.GetDeclaredReferencingForeignKeys().Any(fk => fk.IsOwnership))))
{
@@ -141,8 +139,7 @@ protected virtual void GenerateEntityTypes(
}
foreach (var entityType in entityTypes.Where(
- e => !e.HasDefiningNavigation()
- && e.FindOwnership() == null
+ e => e.FindOwnership() == null
&& e.GetDeclaredNavigations().Any(n => !n.IsOnDependent && !n.ForeignKey.IsOwnership)))
{
stringBuilder.AppendLine();
@@ -169,13 +166,21 @@ protected virtual void GenerateEntityType(
var ownership = entityType.FindOwnership();
var ownerNavigation = ownership?.PrincipalToDependent.Name;
+ var entityTypeName = entityType.Name;
+ if (ownerNavigation != null
+ && entityType.HasSharedClrType
+ && entityTypeName == ownership.PrincipalEntityType.GetOwnedName(entityType.ClrType.ShortDisplayName(), ownerNavigation))
+ {
+ entityTypeName = entityType.ClrType.DisplayName();
+ }
+
stringBuilder
.Append(builderName)
.Append(
ownerNavigation != null
? ownership.IsUnique ? ".OwnsOne(" : ".OwnsMany("
: ".Entity(")
- .Append(Code.Literal(entityType.Name));
+ .Append(Code.Literal(entityTypeName));
if (ownerNavigation != null)
{
diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs
index 3a47094ab04..6b6cadbc927 100644
--- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs
@@ -1399,8 +1399,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
var targetEntityType = navigation.TargetEntityType;
if (targetEntityType == null
- || (!targetEntityType.HasDefiningNavigation()
- && !targetEntityType.IsOwned()))
+ || !targetEntityType.IsOwned())
{
return null;
}
diff --git a/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs b/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs
index a365c773f4b..eab3a82587d 100644
--- a/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs
+++ b/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs
@@ -39,6 +39,7 @@ public static string EntityTypeNotFoundShared([CanBeNull] object? clrType)
///
/// Cannot create a proxy for '{typeName}' because it is mapped to multiple owned entity types. Proxy creation is not supported for owned types used more than once in the model.
///
+ [Obsolete]
public static string EntityTypeNotFoundWeak([CanBeNull] object? typeName)
=> string.Format(
GetString("EntityTypeNotFoundWeak", nameof(typeName)),
diff --git a/src/EFCore.Proxies/Properties/ProxiesStrings.resx b/src/EFCore.Proxies/Properties/ProxiesStrings.resx
index f6c2654247f..5b15a15a34d 100644
--- a/src/EFCore.Proxies/Properties/ProxiesStrings.resx
+++ b/src/EFCore.Proxies/Properties/ProxiesStrings.resx
@@ -125,6 +125,7 @@
Cannot create a proxy for '{typeName}' because it is mapped to multiple owned entity types. Proxy creation is not supported for owned types used more than once in the model.
+ Obsolete
Property '{property}' on entity type '{entityType}' is mapped without a CLR property. 'UseChangeTrackingProxies' requires all entity types to be public, unsealed, have virtual properties, and have a public or protected constructor. 'UseLazyLoadingProxies' requires only the navigation properties be virtual.
diff --git a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
index b4198381f78..aae68a69ba8 100644
--- a/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
+++ b/src/EFCore.Proxies/Proxies/Internal/ProxyFactory.cs
@@ -46,11 +46,6 @@ public virtual object Create(
throw new InvalidOperationException(ProxiesStrings.EntityTypeNotFoundShared(type.ShortDisplayName()));
}
- if (context.Model.HasEntityTypeWithDefiningNavigation(type))
- {
- throw new InvalidOperationException(ProxiesStrings.EntityTypeNotFoundWeak(type.ShortDisplayName()));
- }
-
throw new InvalidOperationException(CoreStrings.EntityTypeNotFound(type.ShortDisplayName()));
}
diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
index 211ad8c6650..5cfdaab23dc 100644
--- a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
+++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
@@ -63,12 +63,16 @@ public static string GetDefaultTableName([NotNull] this IEntityType entityType,
}
var name = entityType.ShortName();
- if (entityType.HasDefiningNavigation())
+ if (entityType.HasSharedClrType
+ && ownership != null
+#pragma warning disable EF1001 // Internal EF Core API usage.
+ && entityType.Name == ownership.PrincipalEntityType.GetOwnedName(name, ownership.PrincipalToDependent.Name))
+#pragma warning restore EF1001 // Internal EF Core API usage.
{
- var definingTypeName = entityType.DefiningEntityType.GetTableName();
- name = definingTypeName != null
- ? $"{definingTypeName}_{entityType.DefiningNavigationName}"
- : $"{entityType.DefiningNavigationName}_{name}";
+ var ownerTypeTable = ownership.PrincipalEntityType.GetTableName();
+ name = ownerTypeTable != null
+ ? $"{ownerTypeTable}_{ownership.PrincipalToDependent.Name}"
+ : $"{ownership.PrincipalToDependent.Name}_{name}";
}
return truncate
@@ -141,31 +145,23 @@ public static string GetSchema([NotNull] this IEntityType entityType)
public static string GetDefaultSchema([NotNull] this IEntityType entityType)
{
var ownership = entityType.FindOwnership();
- if (ownership != null
- && ownership.IsUnique)
+ if (ownership != null)
{
return ownership.PrincipalEntityType.GetSchema();
}
- if (entityType.HasDefiningNavigation())
+ var skipNavigationSchema = entityType.GetForeignKeys().SelectMany(fk => fk.GetReferencingSkipNavigations())
+ .FirstOrDefault(n => !n.IsOnDependent)
+ ?.DeclaringEntityType.GetSchema();
+ if (skipNavigationSchema != null
+ && entityType.GetForeignKeys().SelectMany(fk => fk.GetReferencingSkipNavigations())
+ .Where(n => !n.IsOnDependent)
+ .All(n => n.DeclaringEntityType.GetSchema() == skipNavigationSchema))
{
- return entityType.DefiningEntityType.GetSchema() ?? entityType.Model.GetDefaultSchema();
+ return skipNavigationSchema;
}
- else
- {
- var skipReferencingTypes = entityType.GetForeignKeys().SelectMany(fk => fk.GetReferencingSkipNavigations())
- .Where(n => !n.IsOnDependent && n.DeclaringEntityType != entityType)
- .ToList();
- var skipNavigationSchema = skipReferencingTypes.FirstOrDefault()?.DeclaringEntityType.GetSchema();
- if (skipNavigationSchema != null
- && skipReferencingTypes.Skip(1)
- .All(n => n.DeclaringEntityType.GetSchema() == skipNavigationSchema))
- {
- return skipNavigationSchema;
- }
- return entityType.Model.GetDefaultSchema();
- }
+ return entityType.Model.GetDefaultSchema();
}
///
diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
index 766a03f1929..49c4cf841d3 100644
--- a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
+++ b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
@@ -230,7 +230,8 @@ public static IModel Add(
private static void AddDefaultMappings(RelationalModel databaseModel, IConventionEntityType entityType)
{
- var name = entityType.GetRootType().FullName();
+ var rootType = entityType.GetRootType();
+ var name = rootType.HasSharedClrType ? rootType.FullName() : rootType.ShortName();
if (!databaseModel.DefaultTables.TryGetValue(name, out var defaultTable))
{
defaultTable = new TableBase(name, null, databaseModel);
diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
index 606934bcafc..ed8e9dd6a4d 100644
--- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
+++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
@@ -947,39 +947,24 @@ private static bool EntityTypePathEquals(IEntityType source, IEntityType target,
return false;
}
- if (GetDefiningNavigationName(source) != GetDefiningNavigationName(target))
- {
- return false;
- }
-
- var nextSource = source.DefiningEntityType;
- var nextTarget = target.DefiningEntityType;
+ var nextSource = GetLinkedPrincipal(source);
+ var nextTarget = GetLinkedPrincipal(target);
return (nextSource == null && nextTarget == null)
|| (nextSource != null
&& nextTarget != null
&& EntityTypePathEquals(nextSource, nextTarget, diffContext));
}
- private static string GetDefiningNavigationName(IEntityType entityType)
+ private static IEntityType GetLinkedPrincipal(IEntityType entityType)
{
- if (entityType.DefiningNavigationName != null)
+ var table = StoreObjectIdentifier.Create(entityType, StoreObjectType.Table);
+ if (table == null)
{
- return entityType.DefiningNavigationName;
- }
-
- var primaryKey = entityType.BaseType == null ? entityType.FindPrimaryKey() : null;
- if (primaryKey != null)
- {
- var definingForeignKey = entityType
- .FindForeignKeys(primaryKey.Properties)
- .FirstOrDefault(fk => fk.PrincipalEntityType.GetTableName() == entityType.GetTableName());
- if (definingForeignKey?.DependentToPrincipal != null)
- {
- return definingForeignKey.DependentToPrincipal.Name;
- }
+ return null;
}
- return entityType.Name;
+ var linkingForeignKey = entityType.FindRowInternalForeignKeys(table.Value).FirstOrDefault();
+ return linkingForeignKey?.PrincipalEntityType;
}
///
diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
index 6733c34d8fc..b7617837b82 100644
--- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs
@@ -1349,8 +1349,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
var targetEntityType = navigation.TargetEntityType;
if (targetEntityType == null
- || (!targetEntityType.HasDefiningNavigation()
- && !targetEntityType.IsOwned()))
+ || !targetEntityType.IsOwned())
{
return null;
}
diff --git a/src/EFCore.Relational/Update/Internal/ModificationCommandComparer.cs b/src/EFCore.Relational/Update/Internal/ModificationCommandComparer.cs
index 430086c6877..14517311d54 100644
--- a/src/EFCore.Relational/Update/Internal/ModificationCommandComparer.cs
+++ b/src/EFCore.Relational/Update/Internal/ModificationCommandComparer.cs
@@ -47,20 +47,20 @@ public virtual int Compare(ModificationCommand x, ModificationCommand y)
}
result = StringComparer.Ordinal.Compare(x.Schema, y.Schema);
- if (0 != result)
+ if (result != 0)
{
return result;
}
result = StringComparer.Ordinal.Compare(x.TableName, y.TableName);
- if (0 != result)
+ if (result != 0)
{
return result;
}
var xState = x.EntityState;
result = (int)xState - (int)y.EntityState;
- if (0 != result)
+ if (result != 0)
{
return result;
}
@@ -77,13 +77,7 @@ public virtual int Compare(ModificationCommand x, ModificationCommand y)
if (xEntityType != yEntityType)
{
result = StringComparer.Ordinal.Compare(xEntityType.Name, yEntityType.Name);
- if (0 != result)
- {
- return result;
- }
-
- result = StringComparer.Ordinal.Compare(xEntityType.DefiningNavigationName, yEntityType.DefiningNavigationName);
- if (0 != result)
+ if (result != 0)
{
return result;
}
@@ -95,7 +89,7 @@ public virtual int Compare(ModificationCommand x, ModificationCommand y)
var xKeyProperty = xKey.Properties[i];
result = xKeyProperty.GetCurrentValueComparer().Compare(xEntry, yEntry);
- if (0 != result)
+ if (result != 0)
{
return result;
}
diff --git a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs
index 7d8e53c4087..ef743d3716e 100644
--- a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs
+++ b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs
@@ -26,7 +26,7 @@ public class EntityReferenceMap
private Dictionary
- The entity type '{entityType}' has a defining navigation and the supplied entity is currently referenced from several owner entities. To access the entry for a particular reference, call '{targetEntryCall}' on the owner entry.
+ The entity type '{entityType}' uses a shared type and the supplied entity is currently referenced from several owner entities. To access the entry for a particular reference, call '{targetEntryCall}' on the owner entry.
The foreign key {foreignKeyProperties} on entity type '{entityType}' cannot be configured as having a required dependent since the dependent side cannot be determined. To identify the dependent side of the relationship, configure the foreign key property in 'OnModelCreating'. See http://go.microsoft.com/fwlink/?LinkId=724062 for more details.
@@ -147,6 +147,9 @@
The service property '{property}' of type '{serviceType}' cannot be added to the entity type '{entityType}' because there is another property of the same type. Ignore one of the properties using the [NotMapped] attribute or 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
+
+ The shared type entity type '{entityType}' cannot be added to the model because its name is the same as the CLR type name. This usually indicates an error, either add it as a non-shared entity type or choose a different name.
+
The annotation '{annotation}' was not found. Ensure that the annotation has been added to the object {annotatable}
@@ -231,6 +234,7 @@
The entity type '{entityType}' with a defining navigation cannot be added to the model because an entity type with the same name already exists.
+ Obsolete
The type '{entityType}' cannot be configured as non-owned because an owned entity type with the same name already exists.
@@ -240,6 +244,7 @@
The entity type '{entityType}' cannot be added to the model because an entity type with a defining navigation with the same name already exists.
+ Obsolete
The client projection contains a reference to a constant expression of '{constantType}' which is being passed as an argument to the method '{methodName}'. This could potentially cause a memory leak; consider assigning this constant to a local variable and using the variable in the query instead. See https://go.microsoft.com/fwlink/?linkid=2103067 for more information.
@@ -471,6 +476,7 @@
The foreign keys on entity type '{dependentType}' cannot target the same entity type because it has a defining navigation.
+ Obsolete
The types of the properties specified for the foreign key {foreignKeyProperties} on entity type '{dependentType}' do not match the types of the properties in the principal key {principalKeyProperties} on entity type '{principalType}'. Provide properties that use the same types in the same order.
@@ -527,6 +533,7 @@
The entity type '{ownedEntityType}' is configured as owned, but the entity type '{nonOwnedEntityType}' is not. Configure all entity types with defining navigations sharing a CLR type as owned in 'OnModelCreating'.
+ Obsolete
The specified index properties {indexProperties} are not declared on the entity type '{entityType}'. Ensure that index properties are declared on the target entity type.
@@ -602,6 +609,7 @@
Cannot create a DbSet for '{typeName}' because it is mapped to multiple entity types with defining navigations and should be accessed through the owning entities.
+ Obsolete
Invalid {name}: {value}
@@ -801,7 +809,7 @@
The navigation '{targetEntityType}.{inverseNavigation}' specified in the [InverseProperty] attribute cannot be used as the inverse of '{weakEntityType}.{navigation}' because it's not the defining navigation '{definingNavigation}'.
- Warning CoreEventId.NonDefiningInverseNavigationWarning string string string string string
+ Obsolete Warning CoreEventId.NonDefiningInverseNavigationWarning string string string string string
The navigation '{navigation}' is non-nullable, causing the entity type '{entityType}' to be configured as the dependent side in the corresponding relationship.
@@ -1039,6 +1047,7 @@
The navigation '{navigation}' used to define the entity type '{entityType}' is not present on '{definingEntityType}'.
+ Obsolete
Cannot set the discriminator value for entity type '{entityType}' because the root entity type '{rootEntityType}' doesn't have a discriminator property configured.
@@ -1082,6 +1091,7 @@
The entity type '{2_entityType}' owned by '{0_ownershipNavigation}' should use defining navigation '{1_definingNavigation}' for .
+ Obsolete
The DbContextOptions passed to the {contextType} constructor must be a DbContextOptions<{contextType}>. When registering multiple DbContext types, make sure that the constructor for each context type has a DbContextOptions<TContext> parameter rather than a non-generic DbContextOptions parameter.
@@ -1423,7 +1433,7 @@
An unnamed index specified via [Index] attribute on the entity type '{entityType}' references properties {indexProperties}, but no property with name '{propertyName}' exists on that entity type or any of its base types.
- The entity type '{entityType}' has a defining navigation and the supplied entity is currently not being tracked. To start tracking this entity, call '{referenceCall}' or '{collectionCall}' on the owner entry.
+ The entity type '{entityType}' uses a shared type and the supplied entity is currently not being tracked. To start tracking this entity, call '{referenceCall}' or '{collectionCall}' on the owner entry.
The value for property '{1_entityType}.{0_property}' cannot be set to null because its type is '{propertyType}' which is not a nullable type.
@@ -1439,9 +1449,11 @@
The type '{entityType}' cannot have entity type '{baseType}' as the base type because the latter has a defining navigation.
+ Obsolete
The entity type '{entityType}' cannot have a base type because it has a defining navigation.
+ Obsolete
Property '{1_entityType}.{0_property}' is of type '{actualType}' but the generic type provided is of type '{genericType}'.
diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs
index b106a121cb1..dec14dd801c 100644
--- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs
+++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs
@@ -151,8 +151,7 @@ protected Expression ExpandNavigation(
bool derivedTypeConversion)
{
var targetType = navigation.TargetEntityType;
- if (targetType.HasDefiningNavigation()
- || targetType.IsOwned())
+ if (targetType.IsOwned())
{
if (entityReference.ForeignKeyExpansionMap.TryGetValue(
(navigation.ForeignKey, navigation.IsOnDependent), out var ownedExpansion))
@@ -344,7 +343,7 @@ private Expression ExpandForeignKey(
var collection = !foreignKey.IsUnique && !onDependent;
var targetType = onDependent ? foreignKey.PrincipalEntityType : foreignKey.DeclaringEntityType;
- Debug.Assert(!targetType.HasDefiningNavigation() && !targetType.IsOwned(), "Owned entity expanding foreign key.");
+ Debug.Assert(!targetType.IsOwned(), "Owned entity expanding foreign key.");
var innerQueryable = new QueryRootExpression(targetType);
var innerSource = (NavigationExpansionExpression)_navigationExpandingExpressionVisitor.Visit(innerQueryable);
diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs
index 0a1d9339115..909b77a931d 100644
--- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs
+++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs
@@ -2201,7 +2201,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded()
}
[ConditionalFact]
- public virtual void Weak_owned_types_are_stored_in_snapshot()
+ public virtual void Shared_owned_types_are_stored_in_snapshot()
{
Test(
builder =>
@@ -2431,8 +2431,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
model =>
{
Assert.Equal(2, model.GetEntityTypes().Count());
+ var testOwner = model.FindEntityType(
+ "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwner");
var testOwnee = model.FindEntityType(
- "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwnee");
+ "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwnee", "OwnedEntities", testOwner);
Assert.NotNull(testOwnee.FindCheckConstraint("CK_TestOwnee_TestEnum_Enum_Constraint"));
});
}
diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryFixture.cs
similarity index 77%
rename from test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs
rename to test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryFixture.cs
index ea161caa181..e4fe89dc95c 100644
--- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs
+++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryFixture.cs
@@ -5,7 +5,7 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public class ComplexNavigationsWeakQueryInMemoryFixture : ComplexNavigationsWeakQueryFixtureBase
+ public class ComplexNavigationsSharedTypeQueryInMemoryFixture : ComplexNavigationsSharedTypeQueryFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;
diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryTest.cs
similarity index 92%
rename from test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs
rename to test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryTest.cs
index 4582a266ecc..c1ccee85fd1 100644
--- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs
+++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryInMemoryTest.cs
@@ -7,12 +7,12 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public class ComplexNavigationsWeakQueryInMemoryTest :
- ComplexNavigationsWeakQueryTestBase
+ public class ComplexNavigationsSharedTypeQueryInMemoryTest :
+ ComplexNavigationsSharedTypeQueryTestBase
{
// ReSharper disable once UnusedParameter.Local
- public ComplexNavigationsWeakQueryInMemoryTest(
- ComplexNavigationsWeakQueryInMemoryFixture fixture,
+ public ComplexNavigationsSharedTypeQueryInMemoryTest(
+ ComplexNavigationsSharedTypeQueryInMemoryFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
diff --git a/test/EFCore.Proxies.Tests/ProxyTests.cs b/test/EFCore.Proxies.Tests/ProxyTests.cs
index d926dbdf97a..a33b7aa7a0c 100644
--- a/test/EFCore.Proxies.Tests/ProxyTests.cs
+++ b/test/EFCore.Proxies.Tests/ProxyTests.cs
@@ -109,24 +109,6 @@ public void CreateProxy_works_for_owned_but_not_weak_entity_types()
Assert.Same(typeof(IsOwnedButNotWeak), context.CreateProxy(typeof(IsOwnedButNotWeak)).GetType().BaseType);
}
- [ConditionalFact] // Issue #22407
- public void CreateProxy_throws_for_weak_entity_types()
- {
- using var context = new NeweyContext();
-
- Assert.Equal(
- ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
- Assert.Throws(() => context.CreateProxy()).Message);
-
- Assert.Equal(
- ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
- Assert.Throws(() => context.CreateProxy(_ => { })).Message);
-
- Assert.Equal(
- ProxiesStrings.EntityTypeNotFoundWeak(nameof(IsWeak)),
- Assert.Throws(() => context.CreateProxy(typeof(IsWeak))).Message);
- }
-
[ConditionalFact]
public void CreateProxy_uses_parameterless_constructor()
{
diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs
similarity index 98%
rename from test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs
rename to test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs
index 6bafa6ed1e2..e5012931e94 100644
--- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs
+++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs
@@ -10,10 +10,10 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public abstract class ComplexNavigationsWeakQueryRelationalTestBase : ComplexNavigationsWeakQueryTestBase
- where TFixture : ComplexNavigationsWeakQueryRelationalFixtureBase, new()
+ public abstract class ComplexNavigationsSharedQueryTypeRelationalTestBase : ComplexNavigationsSharedTypeQueryTestBase
+ where TFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase, new()
{
- protected ComplexNavigationsWeakQueryRelationalTestBase(TFixture fixture)
+ protected ComplexNavigationsSharedQueryTypeRelationalTestBase(TFixture fixture)
: base(fixture)
{
}
diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs
similarity index 91%
rename from test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs
rename to test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs
index 87de2b70043..268166f4ba4 100644
--- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs
+++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs
@@ -7,7 +7,7 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public abstract class ComplexNavigationsWeakQueryRelationalFixtureBase : ComplexNavigationsWeakQueryFixtureBase
+ public abstract class ComplexNavigationsSharedTypeQueryRelationalFixtureBase : ComplexNavigationsSharedTypeQueryFixtureBase
{
public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs
index 7e5544053c5..21a4d03e87b 100644
--- a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs
+++ b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs
@@ -117,28 +117,6 @@ public void Can_get_and_set_schema_name_on_entity_type()
Assert.Null(entityType.GetSchema());
}
- [ConditionalFact]
- public void Can_get_table_and_schema_name_for_non_owned_entity_types_with_defining_navigation()
- {
- var modelBuilder = new ModelBuilder();
-
- var orderType = modelBuilder
- .Entity()
- .Metadata;
-
- var customerType = modelBuilder.Model.AddEntityType(typeof(Customer), nameof(Order.Customer), orderType);
-
- Assert.Equal("Order_Customer", customerType.GetTableName());
-
- orderType.SetTableName(null);
-
- Assert.Equal("Customer_Customer", customerType.GetTableName());
-
- customerType.SetTableName("Customizer");
-
- Assert.Equal("Customizer", customerType.GetTableName());
- }
-
[ConditionalFact]
public void Gets_model_schema_if_schema_on_entity_type_not_set()
{
diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs
index 2e4992a72cb..1a8a676b243 100644
--- a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs
+++ b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs
@@ -158,7 +158,7 @@ private static void AssertViews(IRelationalModel model, Mapping mapping)
Assert.Equal(
new[]
{
- nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails)
+ nameof(Order), nameof(OrderDetails), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address"
},
ordersView.EntityTypeMappings.Select(m => m.EntityType.DisplayName()));
Assert.Equal(
@@ -273,7 +273,7 @@ private static void AssertTables(IRelationalModel model, Mapping mapping)
Assert.Equal(
new[]
{
- nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails)
+ nameof(Order), nameof(OrderDetails), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address"
},
ordersTable.EntityTypeMappings.Select(m => m.EntityType.DisplayName()));
Assert.Equal(
diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryFixtureBase.cs
similarity index 99%
rename from test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs
rename to test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryFixtureBase.cs
index 887bb217528..1eb51222445 100644
--- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs
+++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryFixtureBase.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -12,7 +11,7 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public abstract class ComplexNavigationsWeakQueryFixtureBase : ComplexNavigationsQueryFixtureBase, IQueryFixtureBase
+ public abstract class ComplexNavigationsSharedTypeQueryFixtureBase : ComplexNavigationsQueryFixtureBase, IQueryFixtureBase
{
protected override string StoreName { get; } = "ComplexNavigationsOwned";
diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs
similarity index 84%
rename from test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs
rename to test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs
index 0793f76b94e..2479bc610e2 100644
--- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs
+++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs
@@ -6,32 +6,14 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public abstract class ComplexNavigationsWeakQueryTestBase : ComplexNavigationsQueryTestBase
- where TFixture : ComplexNavigationsWeakQueryFixtureBase, new()
+ public abstract class ComplexNavigationsSharedTypeQueryTestBase : ComplexNavigationsQueryTestBase
+ where TFixture : ComplexNavigationsSharedTypeQueryFixtureBase, new()
{
- protected ComplexNavigationsWeakQueryTestBase(TFixture fixture)
+ protected ComplexNavigationsSharedTypeQueryTestBase(TFixture fixture)
: base(fixture)
{
}
- // Naked instances not supported
- public override Task Entity_equality_empty(bool async)
- {
- return Task.CompletedTask;
- }
-
- public override Task Key_equality_two_conditions_on_same_navigation(bool async)
- {
- return Task.CompletedTask;
- }
-
- public override Task Level4_Include(bool async)
- {
- // Due to level 4 being weak, other tests using l4 as root could cause same query as this one to run
- // generating different SQL
- return Task.CompletedTask;
- }
-
// Self-ref not supported
public override Task Join_navigation_self_ref(bool async)
{
@@ -53,16 +35,6 @@ public override Task Join_condition_optimizations_applied_correctly_when_anonymo
return Task.CompletedTask;
}
- public override Task Include_after_multiple_SelectMany_and_reference_navigation(bool async)
- {
- return Task.CompletedTask;
- }
-
- public override Task Include_after_SelectMany_and_multiple_reference_navigations(bool async)
- {
- return Task.CompletedTask;
- }
-
[ConditionalTheory(Skip = "issue #13560")]
public override Task Multiple_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_joined_together(bool async)
{
diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs
index a5fe74eb331..abe1e8b55eb 100644
--- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs
+++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs
@@ -187,17 +187,6 @@ public virtual async Task Set_throws_for_owned_type(bool async)
exception.Message);
}
- [ConditionalTheory]
- [MemberData(nameof(IsAsyncData))]
- public virtual async Task Set_throws_for_owned_type_with_defining_navigation(bool async)
- {
- var exception = await Assert.ThrowsAsync(() => AssertQuery(async, ss => ss.Set()));
-
- Assert.Equal(
- CoreStrings.InvalidSetTypeWeak(nameof(OwnedAddress)),
- exception.Message);
- }
-
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity(bool async)
diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerFixture.cs
similarity index 76%
rename from test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs
rename to test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerFixture.cs
index 7e41954e257..24e1263b7be 100644
--- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs
+++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerFixture.cs
@@ -5,7 +5,7 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public class ComplexNavigationsWeakQuerySqlServerFixture : ComplexNavigationsWeakQueryRelationalFixtureBase
+ public class ComplexNavigationsSharedTypeQuerySqlServerFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> SqlServerTestStoreFactory.Instance;
diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs
new file mode 100644
index 00000000000..70f2dd76309
--- /dev/null
+++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs
@@ -0,0 +1,293 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Diagnostics;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Microsoft.EntityFrameworkCore.Query
+{
+ public class ComplexNavigationsSharedTypeQuerySqlServerTest : ComplexNavigationsSharedQueryTypeRelationalTestBase<
+ ComplexNavigationsSharedTypeQuerySqlServerFixture>
+ {
+ public ComplexNavigationsSharedTypeQuerySqlServerTest(
+ ComplexNavigationsSharedTypeQuerySqlServerFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : base(fixture)
+ {
+ Fixture.TestSqlLoggerFactory.Clear();
+ //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
+ }
+
+ public override async Task Simple_level1_include(bool async)
+ {
+ await base.Simple_level1_include(async);
+
+ AssertSql(
+ @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id]
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[Id]");
+ }
+
+ public override async Task Simple_level1(bool async)
+ {
+ await base.Simple_level1(async);
+
+ AssertSql(
+ @"SELECT [l].[Id], [l].[Date], [l].[Name]
+FROM [Level1] AS [l]");
+ }
+
+ public override async Task Simple_level1_level2_include(bool async)
+ {
+ await base.Simple_level1_level2_include(async);
+ AssertSql(
+ @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id]
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[Id]
+LEFT JOIN (
+ SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id]
+ FROM [Level1] AS [l2]
+ INNER JOIN (
+ SELECT [l3].[Id]
+ FROM [Level1] AS [l3]
+ INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
+ WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t0] ON [l2].[Id] = [t0].[Id]
+ WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
+) AS [t1] ON [t].[Id] = [t1].[Id]");
+ }
+
+ public override async Task Simple_level1_level2_GroupBy_Count(bool async)
+ {
+ await base.Simple_level1_level2_GroupBy_Count(async);
+
+ AssertSql(
+ @"SELECT COUNT(*)
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [l0].[Id]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[Id]
+LEFT JOIN (
+ SELECT [l2].[Id], [l2].[Level3_Name]
+ FROM [Level1] AS [l2]
+ INNER JOIN (
+ SELECT [l3].[Id]
+ FROM [Level1] AS [l3]
+ INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
+ WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t0] ON [l2].[Id] = [t0].[Id]
+ WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
+) AS [t1] ON [t].[Id] = [t1].[Id]
+GROUP BY [t1].[Level3_Name]");
+ }
+
+ public override async Task Simple_level1_level2_GroupBy_Having_Count(bool async)
+ {
+ await base.Simple_level1_level2_GroupBy_Having_Count(async);
+
+ AssertSql(
+ @"SELECT COUNT(*)
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [l0].[Id]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[Id]
+LEFT JOIN (
+ SELECT [l2].[Id], [l2].[Level3_Name]
+ FROM [Level1] AS [l2]
+ INNER JOIN (
+ SELECT [l3].[Id]
+ FROM [Level1] AS [l3]
+ INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
+ WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t0] ON [l2].[Id] = [t0].[Id]
+ WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
+) AS [t1] ON [t].[Id] = [t1].[Id]
+GROUP BY [t1].[Level3_Name]
+HAVING MIN(COALESCE([t].[Id], 0)) > 0");
+ }
+
+ public override async Task Simple_level1_level2_level3_include(bool async)
+ {
+ await base.Simple_level1_level2_level3_include(async);
+
+ AssertSql(
+ @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t4].[Id], [t4].[Level3_Optional_Id], [t4].[Level3_Required_Id], [t4].[Level4_Name], [t4].[OneToMany_Optional_Inverse4Id], [t4].[OneToMany_Required_Inverse4Id], [t4].[OneToOne_Optional_PK_Inverse4Id]
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[Id]
+LEFT JOIN (
+ SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id]
+ FROM [Level1] AS [l2]
+ INNER JOIN (
+ SELECT [l3].[Id]
+ FROM [Level1] AS [l3]
+ INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
+ WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t0] ON [l2].[Id] = [t0].[Id]
+ WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
+) AS [t1] ON [t].[Id] = [t1].[Id]
+LEFT JOIN (
+ SELECT [l5].[Id], [l5].[Level3_Optional_Id], [l5].[Level3_Required_Id], [l5].[Level4_Name], [l5].[OneToMany_Optional_Inverse4Id], [l5].[OneToMany_Required_Inverse4Id], [l5].[OneToOne_Optional_PK_Inverse4Id]
+ FROM [Level1] AS [l5]
+ INNER JOIN (
+ SELECT [l6].[Id]
+ FROM [Level1] AS [l6]
+ INNER JOIN (
+ SELECT [l7].[Id]
+ FROM [Level1] AS [l7]
+ INNER JOIN [Level1] AS [l8] ON [l7].[Id] = [l8].[Id]
+ WHERE [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t2] ON [l6].[Id] = [t2].[Id]
+ WHERE [l6].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l6].[Level2_Required_Id] IS NOT NULL
+ ) AS [t3] ON [l5].[Id] = [t3].[Id]
+ WHERE [l5].[OneToMany_Required_Inverse4Id] IS NOT NULL AND [l5].[Level3_Required_Id] IS NOT NULL
+) AS [t4] ON [t1].[Id] = [t4].[Id]");
+ }
+
+ public override async Task Nested_group_join_with_take(bool async)
+ {
+ await base.Nested_group_join_with_take(async);
+
+ AssertSql(
+ @"@__p_0='2'
+
+SELECT [t3].[Level2_Name]
+FROM (
+ SELECT TOP(@__p_0) [l].[Id], [t0].[Id0] AS [Id00]
+ FROM [Level1] AS [l]
+ LEFT JOIN (
+ SELECT [t].[Id] AS [Id0], [t].[Level1_Optional_Id]
+ FROM [Level1] AS [l0]
+ LEFT JOIN (
+ SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id]
+ FROM [Level1] AS [l1]
+ INNER JOIN [Level1] AS [l2] ON [l1].[Id] = [l2].[Id]
+ WHERE [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t] ON [l0].[Id] = [t].[Id]
+ WHERE ([t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL) AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL
+ ) AS [t0] ON [l].[Id] = [t0].[Level1_Optional_Id]
+ ORDER BY [l].[Id]
+) AS [t1]
+LEFT JOIN (
+ SELECT [t2].[Level1_Optional_Id], [t2].[Level2_Name]
+ FROM [Level1] AS [l3]
+ LEFT JOIN (
+ SELECT [l4].[Id], [l4].[OneToOne_Required_PK_Date], [l4].[Level1_Optional_Id], [l4].[Level1_Required_Id], [l4].[Level2_Name], [l4].[OneToMany_Required_Inverse2Id]
+ FROM [Level1] AS [l4]
+ INNER JOIN [Level1] AS [l5] ON [l4].[Id] = [l5].[Id]
+ WHERE [l4].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l4].[Level1_Required_Id] IS NOT NULL AND [l4].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t2] ON [l3].[Id] = [t2].[Id]
+ WHERE ([t2].[OneToOne_Required_PK_Date] IS NOT NULL AND [t2].[Level1_Required_Id] IS NOT NULL) AND [t2].[OneToMany_Required_Inverse2Id] IS NOT NULL
+) AS [t3] ON [t1].[Id00] = [t3].[Level1_Optional_Id]
+ORDER BY [t1].[Id]");
+ }
+
+ public override async Task Explicit_GroupJoin_in_subquery_with_unrelated_projection2(bool async)
+ {
+ await base.Explicit_GroupJoin_in_subquery_with_unrelated_projection2(async);
+
+ AssertSql(
+ @"SELECT [t1].[Id]
+FROM (
+ SELECT DISTINCT [l].[Id], [l].[Date], [l].[Name]
+ FROM [Level1] AS [l]
+ LEFT JOIN (
+ SELECT [t].[Level1_Optional_Id], [t].[Level2_Name]
+ FROM [Level1] AS [l0]
+ LEFT JOIN (
+ SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Level2_Name], [l1].[OneToMany_Required_Inverse2Id]
+ FROM [Level1] AS [l1]
+ INNER JOIN [Level1] AS [l2] ON [l1].[Id] = [l2].[Id]
+ WHERE [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t] ON [l0].[Id] = [t].[Id]
+ WHERE ([t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL) AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL
+ ) AS [t0] ON [l].[Id] = [t0].[Level1_Optional_Id]
+ WHERE ([t0].[Level2_Name] <> N'Foo') OR [t0].[Level2_Name] IS NULL
+) AS [t1]");
+ }
+
+ public override async Task Result_operator_nav_prop_reference_optional_via_DefaultIfEmpty(bool async)
+ {
+ await base.Result_operator_nav_prop_reference_optional_via_DefaultIfEmpty(async);
+
+ AssertSql(
+ @"SELECT COALESCE(SUM(CASE
+ WHEN ([t0].[OneToOne_Required_PK_Date] IS NULL OR [t0].[Level1_Required_Id] IS NULL) OR [t0].[OneToMany_Required_Inverse2Id] IS NULL THEN 0
+ ELSE [t0].[Level1_Required_Id]
+END), 0)
+FROM [Level1] AS [l]
+LEFT JOIN (
+ SELECT [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[OneToMany_Required_Inverse2Id]
+ FROM [Level1] AS [l0]
+ LEFT JOIN (
+ SELECT [l1].[Id], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[OneToMany_Required_Inverse2Id]
+ FROM [Level1] AS [l1]
+ INNER JOIN [Level1] AS [l2] ON [l1].[Id] = [l2].[Id]
+ WHERE [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t] ON [l0].[Id] = [t].[Id]
+ WHERE ([t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL) AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL
+) AS [t0] ON [l].[Id] = [t0].[Level1_Optional_Id]");
+ }
+
+ public override async Task SelectMany_with_Include1(bool async)
+ {
+ await base.SelectMany_with_Include1(async);
+
+ AssertSql(
+ @"SELECT [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l].[Id], [t].[Id0], [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[Id0], [t1].[Id00]
+FROM [Level1] AS [l]
+INNER JOIN (
+ SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l1].[Id] AS [Id0]
+ FROM [Level1] AS [l0]
+ INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
+ WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
+) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id]
+LEFT JOIN (
+ SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [t0].[Id] AS [Id0], [t0].[Id0] AS [Id00]
+ FROM [Level1] AS [l2]
+ INNER JOIN (
+ SELECT [l3].[Id], [l4].[Id] AS [Id0]
+ FROM [Level1] AS [l3]
+ INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
+ WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
+ ) AS [t0] ON [l2].[Id] = [t0].[Id]
+ WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
+) AS [t1] ON [t].[Id] = [t1].[OneToMany_Optional_Inverse3Id]
+ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t1].[Id], [t1].[Id0], [t1].[Id00]");
+ }
+
+ public override async Task SelectMany_with_navigation_and_Distinct(bool async)
+ {
+ var message = (await Assert.ThrowsAsync(
+ () => base.SelectMany_with_navigation_and_Distinct(async))).Message;
+
+ Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyOuterElementOfCollectionJoin, message);
+ }
+
+ private void AssertSql(params string[] expected)
+ => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
+ }
+}
diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs
deleted file mode 100644
index efeb76d3d0b..00000000000
--- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore.Diagnostics;
-using Xunit;
-using Xunit.Abstractions;
-
-namespace Microsoft.EntityFrameworkCore.Query
-{
- public class ComplexNavigationsWeakQuerySqlServerTest : ComplexNavigationsWeakQueryRelationalTestBase<
- ComplexNavigationsWeakQuerySqlServerFixture>
- {
- public ComplexNavigationsWeakQuerySqlServerTest(
- ComplexNavigationsWeakQuerySqlServerFixture fixture,
- ITestOutputHelper testOutputHelper)
- : base(fixture)
- {
- Fixture.TestSqlLoggerFactory.Clear();
- //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
- }
-
- public override async Task Simple_level1_include(bool async)
- {
- await base.Simple_level1_include(async);
-
- AssertSql(
- @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToOne_Required_PK_Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Level2_Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id]
-FROM [Level1] AS [l]");
- }
-
- public override async Task Simple_level1(bool async)
- {
- await base.Simple_level1(async);
-
- AssertSql(
- @"SELECT [l].[Id], [l].[Date], [l].[Name]
-FROM [Level1] AS [l]");
- }
-
- public override async Task Simple_level1_level2_include(bool async)
- {
- await base.Simple_level1_level2_include(async);
-
- AssertSql(
- @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToOne_Required_PK_Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Level2_Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[Level2_Optional_Id], [l].[Level2_Required_Id], [l].[Level3_Name], [l].[OneToMany_Optional_Inverse3Id], [l].[OneToMany_Required_Inverse3Id], [l].[OneToOne_Optional_PK_Inverse3Id]
-FROM [Level1] AS [l]");
- }
-
- public override async Task Simple_level1_level2_GroupBy_Count(bool async)
- {
- await base.Simple_level1_level2_GroupBy_Count(async);
-
- AssertSql(
- @"SELECT COUNT(*)
-FROM [Level1] AS [l]
-GROUP BY [l].[Level3_Name]");
- }
-
- public override async Task Simple_level1_level2_GroupBy_Having_Count(bool async)
- {
- await base.Simple_level1_level2_GroupBy_Having_Count(async);
-
- AssertSql(
- @"SELECT COUNT(*)
-FROM [Level1] AS [l]
-GROUP BY [l].[Level3_Name]
-HAVING MIN(COALESCE([l].[Id], 0)) > 0");
- }
-
- public override async Task Simple_level1_level2_level3_include(bool async)
- {
- await base.Simple_level1_level2_level3_include(async);
-
- AssertSql(
- @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToOne_Required_PK_Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Level2_Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[Level2_Optional_Id], [l].[Level2_Required_Id], [l].[Level3_Name], [l].[OneToMany_Optional_Inverse3Id], [l].[OneToMany_Required_Inverse3Id], [l].[OneToOne_Optional_PK_Inverse3Id], [l].[Level3_Optional_Id], [l].[Level3_Required_Id], [l].[Level4_Name], [l].[OneToMany_Optional_Inverse4Id], [l].[OneToMany_Required_Inverse4Id], [l].[OneToOne_Optional_PK_Inverse4Id]
-FROM [Level1] AS [l]");
- }
-
- public override async Task Nested_group_join_with_take(bool async)
- {
- await base.Nested_group_join_with_take(async);
-
- AssertSql(
- @"@__p_0='2'
-
-SELECT [t1].[Level2_Name]
-FROM (
- SELECT TOP(@__p_0) [l].[Id], [t].[Id0] AS [Id00]
- FROM [Level1] AS [l]
- LEFT JOIN (
- SELECT [l0].[Level1_Optional_Id], [l0].[Id] AS [Id0]
- FROM [Level1] AS [l0]
- WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL
- ) AS [t] ON [l].[Id] = [t].[Level1_Optional_Id]
- ORDER BY [l].[Id]
-) AS [t0]
-LEFT JOIN (
- SELECT [l1].[Level1_Optional_Id], [l1].[Level2_Name]
- FROM [Level1] AS [l1]
- WHERE ([l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL) AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL
-) AS [t1] ON [t0].[Id00] = [t1].[Level1_Optional_Id]
-ORDER BY [t0].[Id]");
- }
-
- public override async Task Explicit_GroupJoin_in_subquery_with_unrelated_projection2(bool async)
- {
- await base.Explicit_GroupJoin_in_subquery_with_unrelated_projection2(async);
-
- AssertSql(
- @"SELECT [t0].[Id]
-FROM (
- SELECT DISTINCT [l].[Id], [l].[Date], [l].[Name]
- FROM [Level1] AS [l]
- LEFT JOIN (
- SELECT [l0].[Level1_Optional_Id], [l0].[Level2_Name]
- FROM [Level1] AS [l0]
- WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL
- ) AS [t] ON [l].[Id] = [t].[Level1_Optional_Id]
- WHERE ([t].[Level2_Name] <> N'Foo') OR [t].[Level2_Name] IS NULL
-) AS [t0]");
- }
-
- public override async Task Result_operator_nav_prop_reference_optional_via_DefaultIfEmpty(bool async)
- {
- await base.Result_operator_nav_prop_reference_optional_via_DefaultIfEmpty(async);
-
- AssertSql(
- @"SELECT COALESCE(SUM(CASE
- WHEN ([t].[OneToOne_Required_PK_Date] IS NULL OR [t].[Level1_Required_Id] IS NULL) OR [t].[OneToMany_Required_Inverse2Id] IS NULL THEN 0
- ELSE [t].[Level1_Required_Id]
-END), 0)
-FROM [Level1] AS [l]
-LEFT JOIN (
- SELECT [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[OneToMany_Required_Inverse2Id]
- FROM [Level1] AS [l0]
- WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL
-) AS [t] ON [l].[Id] = [t].[Level1_Optional_Id]");
- }
-
- public override async Task SelectMany_with_Include1(bool async)
- {
- await base.SelectMany_with_Include1(async);
-
- AssertSql(
- @"SELECT [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l].[Id], [t].[Id0], [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Level3_Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[Id0], [t1].[Id00]
-FROM [Level1] AS [l]
-INNER JOIN (
- SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l1].[Id] AS [Id0]
- FROM [Level1] AS [l0]
- INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id]
- WHERE [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToOne_Required_PK_Date] IS NOT NULL)
-) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id]
-LEFT JOIN (
- SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [t0].[Id] AS [Id0], [t0].[Id0] AS [Id00]
- FROM [Level1] AS [l2]
- INNER JOIN (
- SELECT [l3].[Id], [l4].[Id] AS [Id0]
- FROM [Level1] AS [l3]
- INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id]
- WHERE [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l3].[Level1_Required_Id] IS NOT NULL AND [l3].[OneToOne_Required_PK_Date] IS NOT NULL)
- ) AS [t0] ON [l2].[Id] = [t0].[Id]
- WHERE [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL AND [l2].[Level2_Required_Id] IS NOT NULL
-) AS [t1] ON [t].[Id] = [t1].[OneToMany_Optional_Inverse3Id]
-ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t1].[Id], [t1].[Id0], [t1].[Id00]");
- }
-
- public override async Task SelectMany_with_navigation_and_Distinct(bool async)
- {
- var message = (await Assert.ThrowsAsync(
- () => base.SelectMany_with_navigation_and_Distinct(async))).Message;
-
- Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyOuterElementOfCollectionJoin, message);
- }
-
- private void AssertSql(params string[] expected)
- => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
- }
-}
diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteFixture.cs
similarity index 76%
rename from test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs
rename to test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteFixture.cs
index 79746dc27a7..b82031a326e 100644
--- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs
+++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteFixture.cs
@@ -5,7 +5,7 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public class ComplexNavigationsWeakQuerySqliteFixture : ComplexNavigationsWeakQueryRelationalFixtureBase
+ public class ComplexNavigationsSharedTypeQuerySqliteFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> SqliteTestStoreFactory.Instance;
diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs
similarity index 70%
rename from test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs
rename to test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs
index a8beeb32908..715f67baf6a 100644
--- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs
+++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs
@@ -10,10 +10,10 @@
namespace Microsoft.EntityFrameworkCore.Query
{
- public class ComplexNavigationsWeakQuerySqliteTest : ComplexNavigationsWeakQueryRelationalTestBase<
- ComplexNavigationsWeakQuerySqliteFixture>
+ public class ComplexNavigationsSharedTypeQuerySqliteTest : ComplexNavigationsSharedQueryTypeRelationalTestBase<
+ ComplexNavigationsSharedTypeQuerySqliteFixture>
{
- public ComplexNavigationsWeakQuerySqliteTest(ComplexNavigationsWeakQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper)
+ public ComplexNavigationsSharedTypeQuerySqliteTest(ComplexNavigationsSharedTypeQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
}
@@ -74,5 +74,23 @@ public override async Task Complex_query_with_let_collection_projection_FirstOrD
SqliteStrings.ApplyNotSupported,
(await Assert.ThrowsAsync(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault(async))).Message);
+
+ public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async)
+ => Assert.Equal(
+ SqliteStrings.ApplyNotSupported,
+ (await Assert.ThrowsAsync(
+ () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(async))).Message);
+
+ public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async)
+ => Assert.Equal(
+ SqliteStrings.ApplyNotSupported,
+ (await Assert.ThrowsAsync(
+ () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(async))).Message);
+
+ public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async)
+ => Assert.Equal(
+ SqliteStrings.ApplyNotSupported,
+ (await Assert.ThrowsAsync(
+ () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(async))).Message);
}
}
diff --git a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs
index 3d923f4a913..58a962e0b08 100644
--- a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs
+++ b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs
@@ -118,7 +118,7 @@ public void Can_get_owned_entity_entry()
Assert.Equal(
CoreStrings.UntrackedDependentEntity(
- typeof(ChildPN).ShortDisplayName(),
+ nameof(ChildPN),
".Reference().TargetEntry",
".Collection().FindEntry()"),
Assert.Throws(() => context.Entry(dependent)).Message);
@@ -132,7 +132,7 @@ public void Can_get_owned_entity_entry()
Assert.NotNull(dependentEntry2);
Assert.Equal(
CoreStrings.AmbiguousDependentEntity(
- typeof(ChildPN).ShortDisplayName(),
+ nameof(ChildPN),
"." + nameof(EntityEntry.Reference) + "()." + nameof(ReferenceEntry.TargetEntry)),
Assert.Throws(() => context.Entry(dependent)).Message);
}
@@ -155,8 +155,8 @@ public void Adding_duplicate_owned_entity_throws_by_default()
CoreStrings.WarningAsErrorTemplate(
CoreEventId.DuplicateDependentEntityTypeInstanceWarning.ToString(),
CoreResources.LogDuplicateDependentEntityTypeInstance(new TestLogger()).GenerateMessage(
- typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + typeof(ChildPN).ShortDisplayName(),
- typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + typeof(ChildPN).ShortDisplayName()),
+ typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN),
+ typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN)),
"CoreEventId.DuplicateDependentEntityTypeInstanceWarning"),
Assert.Throws(() => context.Entry(principal).Reference(p => p.Child2).TargetEntry).Message);
}
@@ -228,13 +228,13 @@ public void Add_principal_with_dependent_unidirectional_nav(EntityState entitySt
var dependentEntry = context.Entry(dependent);
Assert.Equal(principal.Id, dependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, dependentEntry.State);
- Assert.Equal(nameof(ParentPN.Child1), dependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependentEntry.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry.Metadata.DisplayName());
});
}
@@ -309,7 +309,8 @@ public void Add_principal_with_dependent_both_navs(EntityState entityState, bool
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(SubChild),
+ subDependentEntry.Metadata.DisplayName());
});
}
@@ -384,7 +385,8 @@ public void Add_principal_with_dependent_principal_nav(EntityState entityState,
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(Child.SubChild),
+ subDependentEntry.Metadata.DisplayName());
});
}
@@ -519,13 +521,14 @@ public void Add_principal_with_dependent_unidirectional_nav_collection(
var dependentEntry = context.Entry(dependent);
Assert.Equal(principal.Id, dependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, dependentEntry.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), dependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), dependentEntry.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
});
}
@@ -665,7 +668,8 @@ public void Add_principal_with_dependent_both_navs_collection(
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild),
+ subDependentEntry.Metadata.DisplayName());
});
}
@@ -805,7 +809,8 @@ public void Add_principal_with_dependent_principal_nav_collection(
var subDependentEntry = context.Entry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(useTrackGraph == null ? EntityState.Added : entityState, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild),
+ subDependentEntry.Metadata.DisplayName());
});
}
@@ -871,13 +876,13 @@ public void Instance_changed_unidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal).Reference(p => p.Child2).TargetEntry;
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.Child2), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -935,14 +940,14 @@ public void Instance_changed_bidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
Assert.Same(dependent2, subDependent2.Parent);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChild), subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1033,12 +1038,12 @@ public void Instance_changed_unidirectional_collection(EntityState entityState,
Assert.Equal(entityState == EntityState.Added ? EntityState.Detached : EntityState.Deleted, dependentEntry1.State);
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection2), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Equal(principal.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1130,14 +1135,14 @@ public void Instance_changed_bidirectional_collection(EntityState entityState, C
Assert.Equal(entityState == EntityState.Added ? EntityState.Detached : EntityState.Deleted, dependentEntry1.State);
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Same(dependent2, subDependent2.Parent);
Assert.Equal(principal.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChildCollection), subDependentEntry2.Metadata.DefiningNavigationName);
-
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild), subDependentEntry2.Metadata.DisplayName());
+
context.ChangeTracker.CascadeChanges();
Assert.True(context.ChangeTracker.HasChanges());
@@ -1201,13 +1206,14 @@ public void Identity_changed_unidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal).Reference(p => p.Child2).TargetEntry;
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.Child2), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1261,14 +1267,14 @@ public void Identity_changed_bidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
Assert.Same(dependent, subDependent.Parent);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(SubChild), subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1348,13 +1354,14 @@ public void Identity_changed_unidirectional_collection(EntityState entityState,
var dependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection2).FindEntry(dependent);
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection2), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
var subDependentEntry = dependentEntry2.Collection(p => p.SubChildCollection).FindEntry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1434,14 +1441,14 @@ public void Identity_changed_bidirectional_collection(EntityState entityState, C
var dependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection1).FindEntry(dependent);
Assert.Equal(principal.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
Assert.Same(dependent, subDependent.Parent);
var subDependentEntry = dependentEntry2.Collection(p => p.SubChildCollection).FindEntry(subDependent);
Assert.Equal(principal.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild), subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1501,7 +1508,7 @@ public void Identity_swapped_unidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal.Id, dependent1Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent1Entry.State);
- Assert.Equal(nameof(ParentPN.Child1), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependent1Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent1Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -1509,7 +1516,7 @@ public void Identity_swapped_unidirectional(EntityState entityState)
var dependent2Entry = context.Entry(principal).Reference(p => p.Child2).TargetEntry;
Assert.Equal(principal.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent2Entry.State);
- Assert.Equal(nameof(ParentPN.Child2), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN), dependent2Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent2Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -1518,13 +1525,13 @@ public void Identity_swapped_unidirectional(EntityState entityState)
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
var subDependentEntry2 = dependent2Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1588,7 +1595,7 @@ public void Identity_swapped_bidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal.Id, dependent1Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent1Entry.State);
- Assert.Equal(nameof(Parent.Child1), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependent1Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent1Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -1596,7 +1603,7 @@ public void Identity_swapped_bidirectional(EntityState entityState)
var dependent2Entry = context.Entry(principal).Reference(p => p.Child2).TargetEntry;
Assert.Equal(principal.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent2Entry.State);
- Assert.Equal(nameof(Parent.Child2), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child2) + "#" + nameof(Child), dependent2Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent2Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -1606,14 +1613,14 @@ public void Identity_swapped_bidirectional(EntityState entityState)
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(SubChild), subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
Assert.Same(dependent2, subDependent2.Parent);
var subDependentEntry2 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(SubChild), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1696,21 +1703,21 @@ public void Identity_swapped_unidirectional_collection(EntityState entityState,
principal.ChildCollection2 = principal.ChildCollection1;
principal.ChildCollection1 = tempCollection;
- var newDependentEntry1 = context.Entry(principal).Collection(p => p.ChildCollection2)
- .FindEntry(dependent1);
- newDependentEntry1.Property("Id").CurrentValue = dependentEntry1.Property("Id").CurrentValue;
-
- var newDependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection1)
+ var newDependentEntry1 = context.Entry(principal).Collection(p => p.ChildCollection1)
.FindEntry(dependent2);
- newDependentEntry2.Property("Id").CurrentValue = dependentEntry2.Property("Id").CurrentValue;
+ newDependentEntry1.Property("Id").CurrentValue = dependentEntry2.Property("Id").CurrentValue;
+
+ var newDependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection2)
+ .FindEntry(dependent1);
+ newDependentEntry2.Property("Id").CurrentValue = dependentEntry1.Property("Id").CurrentValue;
var newSubDependentEntry1 = newDependentEntry1.Collection(p => p.SubChildCollection)
- .FindEntry(subDependent1);
- newSubDependentEntry1.Property("Id").CurrentValue = subDependentEntry1.Property("Id").CurrentValue;
+ .FindEntry(subDependent2);
+ newSubDependentEntry1.Property("Id").CurrentValue = subDependentEntry2.Property("Id").CurrentValue;
var newSubDependentEntry2 = newDependentEntry2.Collection(p => p.SubChildCollection)
- .FindEntry(subDependent2);
- newSubDependentEntry2.Property("Id").CurrentValue = subDependentEntry2.Property("Id").CurrentValue;
+ .FindEntry(subDependent1);
+ newSubDependentEntry2.Property("Id").CurrentValue = subDependentEntry1.Property("Id").CurrentValue;
context.ChangeTracker.DetectChanges();
@@ -1721,29 +1728,29 @@ public void Identity_swapped_unidirectional_collection(EntityState entityState,
Assert.Contains(principal.ChildCollection1, e => ReferenceEquals(e, dependent2));
Assert.Equal(entityState, context.Entry(principal).State);
- Assert.Equal(principal.Id, newDependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(EntityState.Added, newDependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), newDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(principal.Id, newDependentEntry1.Property("ParentId").CurrentValue);
+ Assert.Equal(EntityState.Added, newDependentEntry1.State);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), newDependentEntry1.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
- newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
+ newDependentEntry1.GetInfrastructure().SharedIdentityEntry?.EntityState);
- Assert.Equal(principal.Id, newDependentEntry1.Property("ParentId").CurrentValue);
- Assert.Equal(EntityState.Added, newDependentEntry1.State);
- Assert.Equal(nameof(ParentPN.ChildCollection2), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(principal.Id, newDependentEntry2.Property("ParentId").CurrentValue);
+ Assert.Equal(EntityState.Added, newDependentEntry2.State);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN), newDependentEntry2.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
- newDependentEntry1.GetInfrastructure().SharedIdentityEntry?.EntityState);
+ newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
Assert.Contains(dependent1.SubChildCollection, e => ReferenceEquals(e, subDependent1));
- Assert.Equal(principal.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
- Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
-
- Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Equal(principal.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN), newSubDependentEntry2.Metadata.DisplayName());
+
+ Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
+ Assert.Equal(principal.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
+ Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN), newSubDependentEntry1.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1756,8 +1763,8 @@ public void Identity_swapped_unidirectional_collection(EntityState entityState,
Assert.False(context.ChangeTracker.HasChanges());
Assert.Equal(5, context.ChangeTracker.Entries().Count());
- Assert.Null(newDependentEntry2.GetInfrastructure().SharedIdentityEntry);
Assert.Null(newDependentEntry1.GetInfrastructure().SharedIdentityEntry);
+ Assert.Null(newDependentEntry2.GetInfrastructure().SharedIdentityEntry);
Assert.True(context.ChangeTracker.Entries().All(e => e.State == EntityState.Unchanged));
Assert.Contains(principal.ChildCollection2, e => ReferenceEquals(e, dependent1));
Assert.Contains(principal.ChildCollection1, e => ReferenceEquals(e, dependent2));
@@ -1825,19 +1832,19 @@ public void Identity_swapped_bidirectional_collection(EntityState entityState, C
principal.ChildCollection2 = principal.ChildCollection1;
principal.ChildCollection1 = tempCollection;
- var newDependentEntry1 = context.Entry(principal).Collection(p => p.ChildCollection2)
- .FindEntry(dependent1);
- newDependentEntry1.Property("Id").CurrentValue = dependentEntry1.Property("Id").CurrentValue;
-
- var newDependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection1)
+ var newDependentEntry1 = context.Entry(principal).Collection(p => p.ChildCollection1)
.FindEntry(dependent2);
- newDependentEntry2.Property("Id").CurrentValue = dependentEntry2.Property("Id").CurrentValue;
+ newDependentEntry1.Property("Id").CurrentValue = dependentEntry2.Property("Id").CurrentValue;
- var newSubDependentEntry1 = newDependentEntry1.Collection(p => p.SubChildCollection)
+ var newDependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection2)
+ .FindEntry(dependent1);
+ newDependentEntry2.Property("Id").CurrentValue = dependentEntry1.Property("Id").CurrentValue;
+
+ var newSubDependentEntry1 = newDependentEntry2.Collection(p => p.SubChildCollection)
.FindEntry(subDependent1);
newSubDependentEntry1.Property("Id").CurrentValue = subDependentEntry1.Property("Id").CurrentValue;
- var newSubDependentEntry2 = newDependentEntry2.Collection(p => p.SubChildCollection)
+ var newSubDependentEntry2 = newDependentEntry1.Collection(p => p.SubChildCollection)
.FindEntry(subDependent2);
newSubDependentEntry2.Property("Id").CurrentValue = subDependentEntry2.Property("Id").CurrentValue;
@@ -1852,31 +1859,31 @@ public void Identity_swapped_bidirectional_collection(EntityState entityState, C
Assert.Contains(principal.ChildCollection1, e => ReferenceEquals(e, dependent2));
Assert.Equal(entityState, context.Entry(principal).State);
- Assert.Equal(principal.Id, newDependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(EntityState.Added, newDependentEntry2.State);
- Assert.Equal(nameof(Parent.ChildCollection1), newDependentEntry2.Metadata.DefiningNavigationName);
- Assert.Equal(
- entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
- newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
-
Assert.Equal(principal.Id, newDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newDependentEntry1.State);
- Assert.Equal(nameof(Parent.ChildCollection2), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), newDependentEntry1.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
newDependentEntry1.GetInfrastructure().SharedIdentityEntry?.EntityState);
+ Assert.Equal(principal.Id, newDependentEntry2.Property("ParentId").CurrentValue);
+ Assert.Equal(EntityState.Added, newDependentEntry2.State);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection2) + "#" + nameof(Child), newDependentEntry2.Metadata.DisplayName());
+ Assert.Equal(
+ entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
+ newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
+
Assert.Contains(dependent1.SubChildCollection, e => ReferenceEquals(e, subDependent1));
Assert.Same(dependent1, subDependent1.Parent);
Assert.Equal(principal.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection2) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild), newSubDependentEntry1.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Same(dependent2, subDependent2.Parent);
Assert.Equal(principal.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild), newSubDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -1889,8 +1896,8 @@ public void Identity_swapped_bidirectional_collection(EntityState entityState, C
Assert.False(context.ChangeTracker.HasChanges());
Assert.Equal(5, context.ChangeTracker.Entries().Count());
- Assert.Null(newDependentEntry2.GetInfrastructure().SharedIdentityEntry);
Assert.Null(newDependentEntry1.GetInfrastructure().SharedIdentityEntry);
+ Assert.Null(newDependentEntry2.GetInfrastructure().SharedIdentityEntry);
Assert.True(context.ChangeTracker.Entries().All(e => e.State == EntityState.Unchanged));
Assert.Contains(principal.ChildCollection2, e => ReferenceEquals(e, dependent1));
Assert.Contains(principal.ChildCollection1, e => ReferenceEquals(e, dependent2));
@@ -1949,13 +1956,14 @@ public void Parent_changed_unidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2028,14 +2036,15 @@ public void Parent_changed_bidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(EntityState.Added, dependentEntry2.State);
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
Assert.Same(dependent, subDependent.Parent);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChild),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2139,14 +2148,15 @@ public void Parent_changed_unidirectional_collection(EntityState entityState, Co
.FindEntry(dependent);
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
var subDependentEntry2 = dependentEntry2.Collection(p => p.SubChildCollection)
.FindEntry(subDependent);
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2250,7 +2260,7 @@ public void Parent_changed_bidirectional_collection(EntityState entityState, Col
.FindEntry(dependent);
Assert.Equal(EntityState.Added, dependentEntry2.State);
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
Assert.Same(dependent, subDependent.Parent);
@@ -2258,7 +2268,7 @@ public void Parent_changed_bidirectional_collection(EntityState entityState, Col
.FindEntry(subDependent);
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChildCollection), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2337,24 +2347,26 @@ public void Parent_swapped_unidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal1).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal1.Id, dependent1Entry.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, dependent1Entry.State);
- Assert.Equal(nameof(ParentPN.Child1), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependent1Entry.Metadata.DisplayName());
var dependent2Entry = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, dependent2Entry.State);
- Assert.Equal(nameof(ParentPN.Child1), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependent2Entry.Metadata.DisplayName());
Assert.Same(subDependent1, dependent1.SubChild);
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal1.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN),
+ subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
var subDependentEntry2 = dependent2Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN),
+ subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2435,26 +2447,28 @@ public void Parent_swapped_bidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal1).Reference(p => p.Child1).TargetEntry;
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, dependent1Entry.State);
Assert.Equal(principal1.Id, dependent1Entry.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.Child1), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependent1Entry.Metadata.DisplayName());
var dependent2Entry = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, dependent2Entry.State);
- Assert.Equal(nameof(Parent.Child1), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependent2Entry.Metadata.DisplayName());
Assert.Same(subDependent1, dependent1.SubChild);
Assert.Same(dependent1, subDependent1.Parent);
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal1.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(Child.SubChild),
+ subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
Assert.Same(dependent2, subDependent2.Parent);
var subDependentEntry2 = dependent2Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(Child.SubChild),
+ subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2568,27 +2582,27 @@ public void Parent_swapped_unidirectional_collection(EntityState entityState, Co
.FindEntry(dependent2);
Assert.Equal(principal1.Id, newDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, newDependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), newDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), newDependentEntry2.Metadata.DisplayName());
var newDependentEntry1 = context.Entry(principal2).Collection(p => p.ChildCollection1)
.FindEntry(dependent1);
Assert.Equal(principal2.Id, newDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, newDependentEntry1.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), newDependentEntry1.Metadata.DisplayName());
Assert.Contains(dependent1.SubChildCollection, e => ReferenceEquals(e, subDependent1));
var newSubDependentEntry1 = newDependentEntry1.Collection(p => p.SubChildCollection)
.FindEntry(subDependent1);
Assert.Equal(principal2.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN), newSubDependentEntry1.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
var newSubDependentEntry2 = newDependentEntry2.Collection(p => p.SubChildCollection)
.FindEntry(subDependent2);
Assert.Equal(principal1.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN), newSubDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2702,13 +2716,13 @@ public void Parent_swapped_bidirectional_collection(EntityState entityState, Col
.FindEntry(dependent2);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, newDependentEntry2.State);
Assert.Equal(principal1.Id, newDependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.ChildCollection1), newDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), newDependentEntry2.Metadata.DisplayName());
var newDependentEntry1 = context.Entry(principal2).Collection(p => p.ChildCollection1)
.FindEntry(dependent1);
Assert.Equal(principal2.Id, newDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(entityState == EntityState.Added ? EntityState.Added : EntityState.Modified, newDependentEntry1.State);
- Assert.Equal(nameof(Parent.ChildCollection1), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), newDependentEntry1.Metadata.DisplayName());
Assert.Contains(dependent1.SubChildCollection, e => ReferenceEquals(e, subDependent1));
Assert.Same(dependent1, subDependent1.Parent);
@@ -2716,7 +2730,8 @@ public void Parent_swapped_bidirectional_collection(EntityState entityState, Col
.FindEntry(subDependent1);
Assert.Equal(principal2.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild),
+ newSubDependentEntry1.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Same(dependent2, subDependent2.Parent);
@@ -2724,7 +2739,8 @@ public void Parent_swapped_bidirectional_collection(EntityState entityState, Col
.FindEntry(subDependent2);
Assert.Equal(principal1.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild),
+ newSubDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2791,13 +2807,14 @@ public void Parent_and_identity_changed_unidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2868,14 +2885,15 @@ public void Parent_and_identity_changed_bidirectional(EntityState entityState)
var dependentEntry2 = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.Child1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Same(subDependent, dependent.SubChild);
Assert.Same(dependent, subDependent.Parent);
var subDependentEntry = dependentEntry2.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChild),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -2967,13 +2985,14 @@ public void Parent_and_identity_changed_unidirectional_collection(EntityState en
var dependentEntry2 = context.Entry(principal2).Collection(p => p.ChildCollection1).FindEntry(dependent);
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
var subDependentEntry = dependentEntry2.Collection(p => p.SubChildCollection).FindEntry(subDependent);
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -3073,14 +3092,14 @@ public void Parent_and_identity_changed_bidirectional_collection(EntityState ent
var dependentEntry2 = context.Entry(principal2).Collection(p => p.ChildCollection1).FindEntry(dependent);
Assert.Equal(principal2.Id, dependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependentEntry2.State);
- Assert.Equal(nameof(Parent.ChildCollection1), dependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), dependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent.SubChildCollection, e => ReferenceEquals(e, subDependent));
Assert.Same(dependent, subDependent.Parent);
var subDependentEntry = dependentEntry2.Collection(p => p.SubChildCollection).FindEntry(subDependent);
Assert.Equal(principal2.Id, subDependentEntry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry.State);
- Assert.Equal(nameof(Child.SubChildCollection), subDependentEntry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(SubChild), subDependentEntry.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -3148,7 +3167,7 @@ public void Parent_and_identity_swapped_unidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal1).Reference(p => p.Child2).TargetEntry;
Assert.Equal(EntityState.Added, dependent1Entry.State);
Assert.Equal(principal1.Id, dependent1Entry.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(ParentPN.Child2), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN), dependent1Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent1Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3156,7 +3175,7 @@ public void Parent_and_identity_swapped_unidirectional(EntityState entityState)
var dependent2Entry = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent2Entry.State);
- Assert.Equal(nameof(ParentPN.Child1), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN), dependent2Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent2Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3165,13 +3184,13 @@ public void Parent_and_identity_swapped_unidirectional(EntityState entityState)
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal1.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
var subDependentEntry2 = dependent2Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.Child1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChild) + "#" + nameof(SubChildPN), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -3250,7 +3269,7 @@ public void Parent_and_identity_swapped_bidirectional(EntityState entityState)
var dependent1Entry = context.Entry(principal1).Reference(p => p.Child2).TargetEntry;
Assert.Equal(EntityState.Added, dependent1Entry.State);
Assert.Equal(principal1.Id, dependent1Entry.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.Child2), dependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child2) + "#" + nameof(Child), dependent1Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent1Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3258,7 +3277,7 @@ public void Parent_and_identity_swapped_bidirectional(EntityState entityState)
var dependent2Entry = context.Entry(principal2).Reference(p => p.Child1).TargetEntry;
Assert.Equal(principal2.Id, dependent2Entry.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, dependent2Entry.State);
- Assert.Equal(nameof(Parent.Child1), dependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child), dependent2Entry.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
dependent1Entry.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3268,14 +3287,14 @@ public void Parent_and_identity_swapped_bidirectional(EntityState entityState)
var subDependentEntry1 = dependent1Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal1.Id, subDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child2) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(Child.SubChild), subDependentEntry1.Metadata.DisplayName());
Assert.Same(subDependent2, dependent2.SubChild);
Assert.Same(dependent2, subDependent2.Parent);
var subDependentEntry2 = dependent2Entry.Reference(p => p.SubChild).TargetEntry;
Assert.Equal(principal2.Id, subDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, subDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChild), subDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.Child1) + "#" + nameof(Child) + "." + nameof(Child.SubChild) + "#" + nameof(Child.SubChild), subDependentEntry2.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -3396,14 +3415,14 @@ public void Parent_and_identity_swapped_unidirectional_collection(EntityState en
Assert.Equal(EntityState.Added, newDependentEntry2.State);
Assert.Equal(principal1.Id, newDependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(ParentPN.ChildCollection2), newDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN), newDependentEntry2.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
Assert.Equal(principal2.Id, newDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newDependentEntry1.State);
- Assert.Equal(nameof(ParentPN.ChildCollection1), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN), newDependentEntry1.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
newDependentEntry1.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3411,12 +3430,14 @@ public void Parent_and_identity_swapped_unidirectional_collection(EntityState en
Assert.Contains(dependent1.SubChildCollection, e => ReferenceEquals(e, subDependent1));
Assert.Equal(principal1.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection2) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ newSubDependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Equal(principal2.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(ChildPN.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(ParentPN).ShortDisplayName() + "." + nameof(ParentPN.ChildCollection1) + "#" + nameof(ChildPN) + "." + nameof(ChildPN.SubChildCollection) + "#" + nameof(SubChildPN),
+ newSubDependentEntry1.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
@@ -3544,14 +3565,14 @@ public void Parent_and_identity_swapped_bidirectional_collection(EntityState ent
Assert.Equal(EntityState.Added, newDependentEntry2.State);
Assert.Equal(principal1.Id, newDependentEntry2.Property("ParentId").CurrentValue);
- Assert.Equal(nameof(Parent.ChildCollection2), newDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection2) + "#" + nameof(Child), newDependentEntry2.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
Assert.Equal(principal2.Id, newDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newDependentEntry1.State);
- Assert.Equal(nameof(Parent.ChildCollection1), newDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child), newDependentEntry1.Metadata.DisplayName());
Assert.Equal(
entityState == EntityState.Added ? null : (EntityState?)EntityState.Deleted,
newDependentEntry2.GetInfrastructure().SharedIdentityEntry?.EntityState);
@@ -3560,13 +3581,13 @@ public void Parent_and_identity_swapped_bidirectional_collection(EntityState ent
Assert.Same(dependent1, subDependent1.Parent);
Assert.Equal(principal1.Id, newSubDependentEntry2.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry2.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry2.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection2) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild), newSubDependentEntry2.Metadata.DisplayName());
Assert.Contains(dependent2.SubChildCollection, e => ReferenceEquals(e, subDependent2));
Assert.Same(dependent2, subDependent2.Parent);
Assert.Equal(principal2.Id, newSubDependentEntry1.Property("ParentId").CurrentValue);
Assert.Equal(EntityState.Added, newSubDependentEntry1.State);
- Assert.Equal(nameof(Child.SubChildCollection), newSubDependentEntry1.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(Parent).ShortDisplayName() + "." + nameof(Parent.ChildCollection1) + "#" + nameof(Child) + "." + nameof(Child.SubChildCollection) + "#" + nameof(Child.SubChild), newSubDependentEntry1.Metadata.DisplayName());
context.ChangeTracker.CascadeChanges();
diff --git a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs
index 950722205ce..d3d4949c544 100644
--- a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs
+++ b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Xunit;
// ReSharper disable AccessToDisposedClosure
@@ -796,11 +797,7 @@ public void Query_ownership_navigations()
Seed();
using var context = new QueryFixupContext();
- // TODO: Infer these includes
- // Issue #2953
var principal = context.Set()
- .Include(o => o.OrderDetails.BillingAddress)
- .Include(o => o.OrderDetails.ShippingAddress)
.Single();
AssertFixup(
@@ -830,12 +827,12 @@ public void Query_ownership_navigations()
var subDependent1Entry = dependentEntry.Reference(p => p.BillingAddress).TargetEntry;
Assert.Equal(principal.Id, subDependent1Entry.Property("OrderDetailsId").CurrentValue);
Assert.Equal(EntityState.Unchanged, subDependent1Entry.State);
- Assert.Equal(nameof(OrderDetails.BillingAddress), subDependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(OrderDetails).DisplayName() + "." + nameof(OrderDetails.BillingAddress) + "#" + typeof(Address).ShortDisplayName(), subDependent1Entry.Metadata.Name);
var subDependent2Entry = dependentEntry.Reference(p => p.ShippingAddress).TargetEntry;
Assert.Equal(principal.Id, subDependent2Entry.Property("OrderDetailsId").CurrentValue);
Assert.Equal(EntityState.Unchanged, subDependent2Entry.State);
- Assert.Equal(nameof(OrderDetails.ShippingAddress), subDependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(OrderDetails).DisplayName() + "." + nameof(OrderDetails.ShippingAddress) + "#" + typeof(Address).ShortDisplayName(), subDependent2Entry.Metadata.Name);
});
}
@@ -917,11 +914,11 @@ public void Query_subowned()
var subDependent1Entry = context.Entry(subDependent1);
Assert.Equal(principal.Id, subDependent1Entry.Property("OrderDetailsId").CurrentValue);
- Assert.Equal(nameof(OrderDetails.BillingAddress), subDependent1Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(OrderDetails).DisplayName() + "." + nameof(OrderDetails.BillingAddress) + "#" + typeof(Address).ShortDisplayName(), subDependent1Entry.Metadata.Name);
var subDependent2Entry = context.Entry(subDependent2);
Assert.Equal(principal.Id, subDependent2Entry.Property("OrderDetailsId").CurrentValue);
- Assert.Equal(nameof(OrderDetails.ShippingAddress), subDependent2Entry.Metadata.DefiningNavigationName);
+ Assert.Equal(typeof(OrderDetails).DisplayName() + "." + nameof(OrderDetails.ShippingAddress) + "#" + typeof(Address).ShortDisplayName(), subDependent2Entry.Metadata.Name);
});
}
diff --git a/test/EFCore.Tests/DbContextTest.cs b/test/EFCore.Tests/DbContextTest.cs
index 02f8df37837..0fc7803accc 100644
--- a/test/EFCore.Tests/DbContextTest.cs
+++ b/test/EFCore.Tests/DbContextTest.cs
@@ -95,23 +95,6 @@ public void Local_does_not_call_DetectChanges_when_disabled()
Assert.Equal(EntityState.Modified, entry.State);
}
- [ConditionalFact]
- public void Set_throws_for_weak_types()
- {
- var model = new Model();
- var question = model.AddEntityType(typeof(Question), ConfigurationSource.Explicit);
- model.AddEntityType(typeof(User), nameof(Question.Author), question, ConfigurationSource.Explicit);
-
- var optionsBuilder = new DbContextOptionsBuilder();
- optionsBuilder
- .UseInMemoryDatabase(Guid.NewGuid().ToString())
- .UseInternalServiceProvider(InMemoryTestHelpers.Instance.CreateServiceProvider())
- .UseModel(model.FinalizeModel());
- using var context = new DbContext(optionsBuilder.Options);
- var ex = Assert.Throws(() => context.Set().Local);
- Assert.Equal(CoreStrings.InvalidSetTypeWeak(nameof(User)), ex.Message);
- }
-
[ConditionalFact]
public void Set_throws_for_shared_types()
{
diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs
index 0813179c5bf..ddf7a0b8ad6 100644
--- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs
+++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs
@@ -682,41 +682,6 @@ public virtual void Passes_on_valid_owned_entity_types()
Validate(modelBuilder.Metadata);
}
- [ConditionalFact]
- public virtual void Detects_weak_entity_type_without_defining_navigation()
- {
- var modelBuilder = CreateConventionlessInternalModelBuilder();
- var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
- entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var anotherEntityTypeBuilder = modelBuilder.Entity(typeof(AnotherSampleEntityMinimal), ConfigurationSource.Convention);
- anotherEntityTypeBuilder.PrimaryKey(new[] { nameof(AnotherSampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var anotherOwnershipBuilder = anotherEntityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(AnotherSampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- anotherOwnershipBuilder.Metadata.DeclaringEntityType.Builder.PrimaryKey(
- anotherOwnershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
-
- var ownershipBuilder = entityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- var ownedTypeBuilder = ownershipBuilder.Metadata.DeclaringEntityType.Builder;
- ownedTypeBuilder.PrimaryKey(ownershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
-
- entityTypeBuilder.Metadata.RemoveNavigation(nameof(SampleEntityMinimal.ReferencedEntity));
- entityTypeBuilder.Ignore(nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Explicit);
-
- VerifyError(
- CoreStrings.NoDefiningNavigation(
- nameof(SampleEntityMinimal.ReferencedEntity),
- nameof(SampleEntityMinimal)
- + "."
- + nameof(SampleEntityMinimal.ReferencedEntity)
- + "#"
- + nameof(ReferencedEntityMinimal),
- nameof(SampleEntityMinimal)),
- modelBuilder.Metadata);
- }
-
[ConditionalFact]
public virtual void Detects_entity_type_with_multiple_ownerships()
{
@@ -746,79 +711,6 @@ public virtual void Detects_entity_type_with_multiple_ownerships()
modelBuilder.Metadata);
}
- [ConditionalFact]
- public virtual void Detects_weak_entity_type_with_non_defining_ownership()
- {
- var modelBuilder = CreateConventionlessInternalModelBuilder();
- var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
- entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var anotherEntityTypeBuilder = modelBuilder.Entity(typeof(AnotherSampleEntityMinimal), ConfigurationSource.Convention);
- anotherEntityTypeBuilder.PrimaryKey(new[] { nameof(AnotherSampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var anotherOwnershipBuilder = anotherEntityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(AnotherSampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- anotherOwnershipBuilder.Metadata.DeclaringEntityType.Builder.PrimaryKey(
- anotherOwnershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
-
- var ownershipBuilder = entityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- var ownedTypeBuilder = ownershipBuilder.Metadata.DeclaringEntityType.Builder;
- ownedTypeBuilder.PrimaryKey(ownershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
-
- ownershipBuilder.Metadata.IsOwnership = false;
- ownedTypeBuilder.HasRelationship(
- entityTypeBuilder.Metadata, (string)null, null, ConfigurationSource.Convention, setTargetAsPrincipal: true)
- .Metadata.IsOwnership = true;
-
- VerifyError(
- CoreStrings.NonDefiningOwnership(
- nameof(SampleEntityMinimal),
- nameof(SampleEntityMinimal.ReferencedEntity),
- nameof(SampleEntityMinimal)
- + "."
- + nameof(SampleEntityMinimal.ReferencedEntity)
- + "#"
- + nameof(ReferencedEntityMinimal)),
- modelBuilder.Metadata);
- }
-
- [ConditionalFact]
- public virtual void Detects_weak_entity_type_without_ownership()
- {
- var modelBuilder = CreateConventionlessInternalModelBuilder();
- var entityTypeBuilder = modelBuilder.Entity(typeof(SampleEntityMinimal), ConfigurationSource.Convention);
- entityTypeBuilder.PrimaryKey(new[] { nameof(SampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var ownershipBuilder = entityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- var ownedTypeBuilder = ownershipBuilder.Metadata.DeclaringEntityType.Builder;
- ownedTypeBuilder.PrimaryKey(ownershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
-
- var anotherEntityTypeBuilder = modelBuilder.Entity(typeof(AnotherSampleEntityMinimal), ConfigurationSource.Convention);
- anotherEntityTypeBuilder.PrimaryKey(new[] { nameof(AnotherSampleEntityMinimal.Id) }, ConfigurationSource.Convention);
-
- var anotherOwnershipBuilder = anotherEntityTypeBuilder.HasOwnership(
- typeof(ReferencedEntityMinimal), nameof(AnotherSampleEntityMinimal.ReferencedEntity), ConfigurationSource.Convention);
- anotherOwnershipBuilder.Metadata.DeclaringEntityType.Builder.PrimaryKey(
- anotherOwnershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention);
- anotherOwnershipBuilder.Metadata.IsOwnership = false;
-
- VerifyError(
- CoreStrings.InconsistentOwnership(
- nameof(SampleEntityMinimal)
- + "."
- + nameof(SampleEntityMinimal.ReferencedEntity)
- + "#"
- + nameof(ReferencedEntityMinimal),
- nameof(AnotherSampleEntityMinimal)
- + "."
- + nameof(AnotherSampleEntityMinimal.ReferencedEntity)
- + "#"
- + nameof(ReferencedEntityMinimal)),
- modelBuilder.Metadata);
- }
-
[ConditionalFact]
public virtual void Detects_principal_owned_entity_type()
{
diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs
index e61ac72914e..b6a27736ba2 100644
--- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs
+++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs
@@ -257,9 +257,9 @@ public void OnEntityTypeAdded_calls_conventions_in_order(bool useBuilder, bool u
{
var conventions = new ConventionSet();
- var convention1 = new EntityTypeAddedConvention(terminate: false, onlyWeak: false);
- var convention2 = new EntityTypeAddedConvention(terminate: true, onlyWeak: false);
- var convention3 = new EntityTypeAddedConvention(terminate: false, onlyWeak: false);
+ var convention1 = new EntityTypeAddedConvention(terminate: false);
+ var convention2 = new EntityTypeAddedConvention(terminate: true);
+ var convention3 = new EntityTypeAddedConvention(terminate: false);
conventions.EntityTypeAddedConventions.Add(convention1);
conventions.EntityTypeAddedConventions.Add(convention2);
conventions.EntityTypeAddedConventions.Add(convention3);
@@ -296,68 +296,14 @@ public void OnEntityTypeAdded_calls_conventions_in_order(bool useBuilder, bool u
Assert.Null(builder.Metadata.FindEntityType(typeof(Order)));
}
- [InlineData(false, false)]
- [InlineData(true, false)]
- [InlineData(false, true)]
- [InlineData(true, true)]
- [ConditionalTheory]
- public void OnEntityTypeAdded_calls_conventions_in_order_for_weak_entity_types(bool useBuilder, bool useScope)
- {
- var conventions = new ConventionSet();
-
- var convention1 = new EntityTypeAddedConvention(terminate: false, onlyWeak: true);
- var convention2 = new EntityTypeAddedConvention(terminate: true, onlyWeak: true);
- var convention3 = new EntityTypeAddedConvention(terminate: false, onlyWeak: true);
- conventions.EntityTypeAddedConventions.Add(convention1);
- conventions.EntityTypeAddedConventions.Add(convention2);
- conventions.EntityTypeAddedConventions.Add(convention3);
-
- var builder = new InternalModelBuilder(new Model(conventions));
- var owner = builder.Entity(typeof(Order), ConfigurationSource.Explicit);
-
- var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null;
-
- if (useBuilder)
- {
- // Add another owned type to trigger making them weak
- owner.HasOwnership(typeof(OrderDetails), nameof(Order.OtherOrderDetails), ConfigurationSource.Convention);
- var result = owner.HasOwnership(typeof(OrderDetails), nameof(Order.OrderDetails), ConfigurationSource.Convention);
-
- Assert.Equal(!useScope, result == null);
- }
- else
- {
- var result = builder.Metadata.AddEntityType(
- typeof(OrderDetails), nameof(Order.OrderDetails), owner.Metadata, ConfigurationSource.Convention);
-
- Assert.Equal(!useScope, result == null);
- }
-
- if (useScope)
- {
- Assert.Equal(0, convention1.Calls);
- Assert.Equal(0, convention2.Calls);
- scope.Dispose();
- }
-
- Assert.Equal(useBuilder ? 2 : 1, convention1.Calls);
- Assert.Equal(useBuilder ? 2 : 1, convention2.Calls);
- Assert.Equal(0, convention3.Calls);
-
- Assert.Empty(builder.Metadata.GetEntityTypes().Where(e => e.HasDefiningNavigation()));
- Assert.Null(builder.Metadata.FindEntityType(typeof(OrderDetails)));
- }
-
private class EntityTypeAddedConvention : IEntityTypeAddedConvention
{
private readonly bool _terminate;
- private readonly bool _onlyWeak;
public int Calls;
- public EntityTypeAddedConvention(bool terminate, bool onlyWeak)
+ public EntityTypeAddedConvention(bool terminate)
{
_terminate = terminate;
- _onlyWeak = onlyWeak;
}
public void ProcessEntityTypeAdded(
@@ -365,29 +311,13 @@ public void ProcessEntityTypeAdded(
IConventionContext context)
{
Assert.Same(entityTypeBuilder, entityTypeBuilder.Metadata.Builder);
- if (entityTypeBuilder.Metadata.HasDefiningNavigation() == _onlyWeak)
- {
- Calls++;
- }
+
+ Calls++;
if (_terminate)
{
- if (entityTypeBuilder.Metadata.HasDefiningNavigation())
- {
- if (_onlyWeak)
- {
- entityTypeBuilder.ModelBuilder.HasNoEntityType(entityTypeBuilder.Metadata);
- context.StopProcessing();
- }
- }
- else
- {
- if (!_onlyWeak)
- {
- entityTypeBuilder.Metadata.Model.RemoveEntityType(entityTypeBuilder.Metadata.Name);
- context.StopProcessing();
- }
- }
+ entityTypeBuilder.Metadata.Model.RemoveEntityType(entityTypeBuilder.Metadata.Name);
+ context.StopProcessing();
}
}
}
diff --git a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs
index e0e6fda7dfa..73a8ec9b7d1 100644
--- a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs
+++ b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs
@@ -928,34 +928,6 @@ public void Does_not_invert_if_both_entity_types_can_have_non_pk_fk_property()
ValidateModel();
}
- [ConditionalFact]
- public void Does_not_invert_if_principal_entity_type_is_defining_the_weak_entity_type()
- {
- PrincipalType.Builder.Property(nameof(PrincipalEntity.DependentEntityKayPee), ConfigurationSource.Convention);
- PrincipalType.Model.RemoveEntityType(typeof(DependentEntity));
-
- var dependentType = PrincipalType.Model.AddEntityType(
- typeof(DependentEntity), nameof(PrincipalEntity.InverseReferenceNav), PrincipalType,
- ConfigurationSource.Convention);
- var relationshipBuilder = dependentType.Builder.HasRelationship(
- PrincipalType, null, nameof(PrincipalEntity.InverseReferenceNav), ConfigurationSource.Convention);
- dependentType.Builder.PrimaryKey(new[] { nameof(DependentEntity.KayPee) }, ConfigurationSource.Convention);
-
- var newRelationshipBuilder = RunConvention(relationshipBuilder);
- Assert.Same(relationshipBuilder, newRelationshipBuilder);
- Assert.Same(dependentType, newRelationshipBuilder.Metadata.DeclaringEntityType);
-
- newRelationshipBuilder = RunConvention(newRelationshipBuilder);
-
- var fk = (IForeignKey)dependentType.GetForeignKeys().Single();
- Assert.Same(dependentType, fk.DeclaringEntityType);
- Assert.Same(fk, newRelationshipBuilder.Metadata);
- Assert.Same(PrimaryKey, fk.PrincipalKey.Properties.Single());
- Assert.True(fk.IsUnique);
-
- ValidateModel();
- }
-
[ConditionalFact]
public void Does_not_invert_if_principal_entity_type_owns_the_weak_entity_type()
{
diff --git a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs
index db579114979..b896f6a89da 100644
--- a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs
+++ b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs
@@ -348,45 +348,6 @@ public void InversePropertyAttribute_does_not_configure_ambiguous_navigations()
nameof(AmbiguousPrincipal.Dependent)), logEntry.Message);
}
- [ConditionalFact]
- public void InversePropertyAttribute_does_not_configure_non_defining_navigation()
- {
- var principalEntityTypeBuilder = CreateInternalEntityTypeBuilder();
-
- var dependentEntityTypeBuilder = principalEntityTypeBuilder.ModelBuilder.Metadata.AddEntityType(
- typeof(Dependent), nameof(Principal.Dependents), principalEntityTypeBuilder.Metadata, ConfigurationSource.Convention)
- .Builder;
-
- dependentEntityTypeBuilder.HasRelationship(
- principalEntityTypeBuilder.Metadata,
- nameof(Dependent.Principal),
- nameof(Principal.Dependents),
- ConfigurationSource.Convention);
-
- Assert.Contains(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependents));
- Assert.DoesNotContain(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependent));
- Assert.Contains(dependentEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Dependent.Principal));
-
- var convention = new InversePropertyAttributeConvention(CreateDependencies());
- convention.ProcessEntityTypeAdded(
- dependentEntityTypeBuilder,
- new ConventionContext(
- dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher));
-
- var logEntry = ListLoggerFactory.Log.Single();
- Assert.Equal(LogLevel.Warning, logEntry.Level);
- Assert.Equal(
- CoreResources.LogNonDefiningInverseNavigation(new TestLogger()).GenerateMessage(
- nameof(Principal), nameof(Principal.Dependent), "Principal.Dependents#Dependent", nameof(Dependent.Principal),
- nameof(Principal.Dependents)), logEntry.Message);
-
- Assert.Contains(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependents));
- Assert.DoesNotContain(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependent));
- Assert.Contains(dependentEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Dependent.Principal));
-
- Validate(dependentEntityTypeBuilder);
- }
-
[ConditionalFact]
public void InversePropertyAttribute_does_not_configure_non_ownership_navigation()
{
diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs
index 12bdfd683bc..ec11734742c 100644
--- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs
+++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs
@@ -137,9 +137,15 @@ public void Display_name_is_entity_type_name_when_no_CLR_type()
"Everything.Is+Awesome>",
CreateModel().AddEntityType("Everything.Is+Awesome>").DisplayName());
+ [ConditionalFact]
+ public void Display_name_is_prettified_for_owned_shared_type()
+ => Assert.Equal(
+ "Is.We#re.Living#Our.Dream",
+ CreateModel().AddEntityType("Everything.Is.We#re.Living#Our.Dream", typeof(Dictionary)).DisplayName());
+
[ConditionalFact]
public void Display_name_is_entity_type_name_when_shared_entity_type()
- => Assert.Equal("PostTag (Dictionary)", CreateModel().AddEntityType("PostTag", typeof(Dictionary)).DisplayName());
+ => Assert.Equal("Everything.Is+PostTag (Dictionary)", CreateModel().AddEntityType("Everything.Is+PostTag", typeof(Dictionary)).DisplayName());
[ConditionalFact]
public void Name_is_prettified_CLR_full_name()
@@ -2581,45 +2587,6 @@ public void Indexes_are_ordered_by_property_count_then_property_names()
Assert.True(new[] { i1, i2, i3, i4 }.SequenceEqual(customerType.GetIndexes()));
}
- [ConditionalFact]
- public void Adding_inheritance_to_weak_entity_types_throws()
- {
- var model = CreateModel();
- var customerType = model.AddEntityType(typeof(Customer));
- var baseType = model.AddEntityType(typeof(BaseType), nameof(Customer.Orders), customerType);
- var orderType = model.AddEntityType(typeof(Order), nameof(Customer.Orders), customerType);
- var derivedType = model.AddEntityType(typeof(SpecialOrder), nameof(Customer.Orders), customerType);
-
- Assert.Equal(
- CoreStrings.WeakDerivedType(
- nameof(Customer) + "." + nameof(Customer.Orders) + "#" + nameof(Order)),
- Assert.Throws(() => orderType.BaseType = baseType).Message);
- Assert.Equal(
- CoreStrings.WeakDerivedType(
- nameof(Customer) + "." + nameof(Customer.Orders) + "#" + nameof(SpecialOrder)),
- Assert.Throws(() => derivedType.BaseType = orderType).Message);
- }
-
- [ConditionalFact]
- public void Adding_non_delegated_inheritance_to_delegated_identity_definition_entity_types_throws()
- {
- var model = CreateModel();
- var customerType = model.AddEntityType(typeof(Customer));
- var baseType = model.AddEntityType(typeof(BaseType));
- var orderType = model.AddEntityType(typeof(Order), nameof(Customer.Orders), customerType);
- var derivedType = model.AddEntityType(typeof(SpecialOrder));
-
- Assert.Equal(
- CoreStrings.WeakDerivedType(
- nameof(Customer) + "." + nameof(Customer.Orders) + "#" + nameof(Order)),
- Assert.Throws(() => orderType.BaseType = baseType).Message);
- Assert.Equal(
- CoreStrings.WeakBaseType(
- typeof(SpecialOrder).DisplayName(fullName: false),
- nameof(Customer) + "." + nameof(Customer.Orders) + "#" + nameof(Order)),
- Assert.Throws(() => derivedType.BaseType = orderType).Message);
- }
-
[ConditionalFact]
public void Change_tracking_from_model_is_used_by_default_regardless_of_CLR_type()
{
@@ -2731,7 +2698,7 @@ public void Change_tracking_can_be_set_to_snapshot_only_for_non_notifying_entiti
}
[ConditionalFact]
- public void Entity_type_with_deeply_nested_owned_weak_types_builds_correctly()
+ public void Entity_type_with_deeply_nested_owned_shared_types_builds_correctly()
{
using var context = new RejectionContext(nameof(RejectionContext));
var entityTypes = context.Model.GetEntityTypes();
@@ -2740,16 +2707,16 @@ public void Entity_type_with_deeply_nested_owned_weak_types_builds_correctly()
new[]
{
"Application",
- "ApplicationVersion",
- "Rejection",
"Application.Attitude#Attitude",
- "ApplicationVersion.Attitude#Attitude",
- "Rejection.FirstTest#FirstTest",
"Application.Attitude#Attitude.FirstTest#FirstTest",
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest",
- "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff",
"Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff",
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff"
+ "ApplicationVersion",
+ "ApplicationVersion.Attitude#Attitude",
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest",
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff",
+ "Rejection",
+ "Rejection.FirstTest#FirstTest",
+ "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff"
}, entityTypes.Select(e => e.DisplayName()).ToList());
}
@@ -2857,11 +2824,11 @@ List GetTypeNames()
{
"Application",
"Attitude",
+ "Attitude.FirstTest#FirstTest", // FirstTest is shared
+ "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // SpecialistStaff is shared
"Rejection",
- "Attitude.FirstTest#FirstTest", // FirstTest is weak
- "Rejection.FirstTest#FirstTest", // FirstTest is weak
- "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // SpecialistStaff is weak
- "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" // SpecialistStaff is weak
+ "Rejection.FirstTest#FirstTest", // FirstTest is shared
+ "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" // SpecialistStaff is shared
}, GetTypeNames());
modelBuilder.Entity(
@@ -2873,10 +2840,10 @@ List GetTypeNames()
"Application",
"ApplicationVersion",
"Attitude",
- "Rejection",
"Attitude.FirstTest#FirstTest",
- "Rejection.FirstTest#FirstTest",
"Attitude.FirstTest#FirstTest.Tester#SpecialistStaff",
+ "Rejection",
+ "Rejection.FirstTest#FirstTest",
"Rejection.FirstTest#FirstTest.Tester#SpecialistStaff"
}, GetTypeNames());
@@ -2884,28 +2851,28 @@ List GetTypeNames()
x => x.Attitude,
amb =>
{
+ amb.OwnsOne(
+ x => x.FirstTest, mb =>
+ {
+ mb.OwnsOne(a => a.Tester);
+ });
+
var typeNames = GetTypeNames();
Assert.Equal(
new[]
{
"Application",
+ "Application.Attitude#Attitude", // Attitude becomes shared
+ "Application.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes shared
+ "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // Attitude becomes shared
"ApplicationVersion",
+ "ApplicationVersion.Attitude#Attitude", // Attitude becomes shared
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes shared
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // Attitude becomes shared
"Rejection",
- "Application.Attitude#Attitude", // Attitude becomes weak
- "ApplicationVersion.Attitude#Attitude", // Attitude becomes weak
"Rejection.FirstTest#FirstTest",
- "Application.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak
- "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff",
- "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // Attitude becomes weak
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" // Attitude becomes weak
+ "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff"
}, typeNames);
-
- amb.OwnsOne(
- x => x.FirstTest, mb =>
- {
- mb.OwnsOne(a => a.Tester);
- });
});
});
@@ -2913,16 +2880,16 @@ List GetTypeNames()
new[]
{
"Application",
- "ApplicationVersion",
- "Rejection",
"Application.Attitude#Attitude",
- "ApplicationVersion.Attitude#Attitude",
- "Rejection.FirstTest#FirstTest",
"Application.Attitude#Attitude.FirstTest#FirstTest",
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest",
- "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff",
"Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff",
- "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff"
+ "ApplicationVersion",
+ "ApplicationVersion.Attitude#Attitude",
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest",
+ "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff",
+ "Rejection",
+ "Rejection.FirstTest#FirstTest",
+ "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff"
}, GetTypeNames());
}
}
diff --git a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
index 96e9299877e..9fc8f99a88b 100644
--- a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
+++ b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
@@ -6,6 +6,7 @@
using System.Linq;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
@@ -329,19 +330,24 @@ public void Can_mark_type_as_owned_type()
Assert.Null(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Convention));
- Assert.Equal(2, model.GetEntityTypes(typeof(Details)).Count);
+ Assert.Equal(2, model.GetEntityTypes(typeof(Details)).Count());
Assert.Equal(
- CoreStrings.ClashingOwnedEntityType(typeof(Details).Name),
+ CoreStrings.ClashingSharedType(typeof(Details).Name),
Assert.Throws(() => modelBuilder.Entity(typeof(Details), ConfigurationSource.Explicit)).Message);
+ Assert.Equal(
+ CoreStrings.ClashingOwnedEntityType(typeof(Details).Name),
+ Assert.Throws(()
+ => modelBuilder.SharedTypeEntity(nameof(Details), typeof(Details), ConfigurationSource.Explicit)).Message);
+
Assert.NotNull(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Explicit));
Assert.False(model.IsOwned(typeof(Details)));
- Assert.NotNull(modelBuilder.Entity(typeof(Details), ConfigurationSource.Explicit));
+ Assert.NotNull(modelBuilder.SharedTypeEntity(nameof(Details), typeof(Details), ConfigurationSource.Explicit));
- Assert.Empty(model.GetEntityTypes(typeof(Details)).Where(e => e.DefiningNavigationName != null));
+ Assert.Empty(model.GetEntityTypes(typeof(Details)).Where(e => !e.HasSharedClrType));
Assert.Null(modelBuilder.Owned(typeof(Details), ConfigurationSource.Convention));
@@ -497,10 +503,9 @@ public void Can_add_shared_type()
Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit));
Assert.Equal(
- CoreStrings.ClashingNonSharedType(typeof(Customer).DisplayName(), typeof(Customer).DisplayName()),
+ CoreStrings.ClashingNonSharedType(typeof(Customer).DisplayName(), typeof(Customer).ShortDisplayName()),
Assert.Throws(
- () =>
- modelBuilder.SharedTypeEntity(typeof(Customer).DisplayName(), typeof(Customer), ConfigurationSource.Explicit))
+ () => modelBuilder.SharedTypeEntity(typeof(Customer).DisplayName(), typeof(Customer), ConfigurationSource.Explicit))
.Message);
}
diff --git a/test/EFCore.Tests/Metadata/Internal/ModelTest.cs b/test/EFCore.Tests/Metadata/Internal/ModelTest.cs
index 4928a0fe6fc..401964a3047 100644
--- a/test/EFCore.Tests/Metadata/Internal/ModelTest.cs
+++ b/test/EFCore.Tests/Metadata/Internal/ModelTest.cs
@@ -143,61 +143,13 @@ public void Can_add_and_remove_shared_entity()
}
[ConditionalFact]
- public void Can_add_weak_entity_types()
+ public void Adding_a_shared_entity_with_same_name_throws()
{
var model = CreateModel();
- var customerType = model.AddEntityType(typeof(Customer));
- var idProperty = customerType.AddProperty(Customer.IdProperty);
- var customerKey = customerType.AddKey(idProperty);
- var dependentOrderType = model.AddEntityType(typeof(Order), nameof(Customer.Orders), customerType);
-
- var fkProperty = dependentOrderType.AddProperty("ShadowId", typeof(int));
- var orderKey = dependentOrderType.AddKey(fkProperty);
- var fk = dependentOrderType.AddForeignKey(fkProperty, customerKey, customerType);
- var index = dependentOrderType.AddIndex(fkProperty);
-
- Assert.Same(fkProperty, dependentOrderType.GetProperties().Single());
- Assert.Same(orderKey, dependentOrderType.GetKeys().Single());
- Assert.Same(fk, dependentOrderType.GetForeignKeys().Single());
- Assert.Same(index, dependentOrderType.GetIndexes().Single());
- Assert.Equal(new[] { customerType, dependentOrderType }, model.GetEntityTypes());
- Assert.True(model.HasEntityTypeWithDefiningNavigation(typeof(Order)));
- Assert.True(model.HasEntityTypeWithDefiningNavigation(typeof(Order).DisplayName()));
- Assert.Same(
- dependentOrderType,
- model.FindEntityType(typeof(Order).DisplayName(), nameof(Customer.Orders), customerType));
- Assert.Same(
- dependentOrderType,
- model.FindEntityType(typeof(Order).DisplayName(), nameof(Customer.Orders), (IEntityType)customerType));
- Assert.Equal(
- CoreStrings.ClashingWeakEntityType(typeof(Order).DisplayName(fullName: false)),
- Assert.Throws(() => model.AddEntityType(typeof(Order))).Message);
- Assert.Equal(
- CoreStrings.ClashingNonWeakEntityType(
- nameof(Customer)
- + "."
- + nameof(Customer.Orders)
- + "#"
- + nameof(Order)
- + "."
- + nameof(Order.Customer)
- + "#"
- + nameof(Customer)),
- Assert.Throws(
- () => model.AddEntityType(typeof(Customer), nameof(Order.Customer), dependentOrderType)).Message);
-
- Assert.Equal(
- CoreStrings.ForeignKeySelfReferencingDependentEntityType(
- nameof(Customer) + "." + nameof(Customer.Orders) + "#" + nameof(Order)),
- Assert.Throws(
- () => dependentOrderType.AddForeignKey(fkProperty, orderKey, dependentOrderType)).Message);
-
- Assert.Same(
- dependentOrderType, model.RemoveEntityType(
- typeof(Order), nameof(Customer.Orders), customerType));
- Assert.Null(((EntityType)dependentOrderType).Builder);
- Assert.Empty(customerType.GetReferencingForeignKeys());
+ Assert.Equal(CoreStrings.AmbiguousSharedTypeEntityTypeName(typeof(Customer).DisplayName()),
+ Assert.Throws(()
+ => model.AddEntityType(typeof(Customer).DisplayName(), typeof(Customer))).Message);
}
[ConditionalFact]
diff --git a/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs b/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs
index 001b7f12976..b5abfeeb696 100644
--- a/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs
@@ -440,7 +440,7 @@ public virtual void Pulling_relationship_to_a_derived_type_with_fk_creates_relat
Assert.Equal(nameof(Order.CustomerId), otherDerivedFk.Properties.Single().Name);
}
- [ConditionalFact]
+ [ConditionalFact(Skip = "Issue #18388")]
public virtual void Can_promote_shadow_fk_to_the_base_type()
{
var modelBuilder = CreateModelBuilder();
diff --git a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs
index 42d314b3e7d..3c249870b82 100644
--- a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs
@@ -6,6 +6,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Xunit;
@@ -542,7 +543,7 @@ public virtual void Can_use_shared_Type_as_join_entity()
Assert.Equal(typeof(Dictionary), shared2.ClrType);
Assert.Equal(
- CoreStrings.ClashingSharedType(typeof(Dictionary).DisplayName()),
+ CoreStrings.ClashingSharedType(typeof(Dictionary).ShortDisplayName()),
Assert.Throws(() => modelBuilder.Entity>()).Message);
modelBuilder.FinalizeModel();
diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs
index e87b1e69164..3555f204a27 100644
--- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs
+++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs
@@ -38,7 +38,7 @@ public override void Reconfiguring_owned_type_as_non_owned_throws()
modelBuilder.Entity().HasOne(c => c.Details)).Message);
}
- //Shadow navigations not supported #3864
+ // Shadow navigations not supported #3864
public override void Can_configure_owned_type_collection_with_one_call()
{
}
@@ -51,11 +51,6 @@ public override void OwnedType_can_derive_from_Collection()
public override void Can_configure_owned_type_collection_with_one_call_afterwards()
{
}
-
- // Owned type's CLR type is not used
- public override void Cannot_add_owned_type_with_same_clr_type_as_shared_type_entity_type()
- {
- }
}
public class NonGenericStringOneToManyType : OneToManyTestBase
diff --git a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs
index 485065f1522..55cab1bcbb3 100644
--- a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs
@@ -1692,7 +1692,7 @@ public virtual void Can_add_shared_type_entity_type()
Assert.NotNull(shared2.FindProperty("Id"));
Assert.Equal(
- CoreStrings.ClashingSharedType(typeof(Dictionary).DisplayName()),
+ CoreStrings.ClashingSharedType(typeof(Dictionary).ShortDisplayName()),
Assert.Throws(() => modelBuilder.Entity>()).Message);
}
@@ -1704,7 +1704,7 @@ public virtual void Cannot_add_shared_type_when_non_shared_exists()
modelBuilder.Entity();
Assert.Equal(
- CoreStrings.ClashingNonSharedType("Shared1", typeof(Customer).DisplayName()),
+ CoreStrings.ClashingNonSharedType("Shared1", nameof(Customer)),
Assert.Throws(() => modelBuilder.SharedTypeEntity("Shared1")).Message);
}
}
diff --git a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs
index 7037505b673..0012239edc3 100644
--- a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs
@@ -2602,7 +2602,7 @@ public virtual void Attempt_to_configure_Navigation_property_which_is_actually_a
}
[ConditionalFact]
- public virtual void Navigation_to_shared_type_is_no_discovered_by_convention()
+ public virtual void Navigation_to_shared_type_is_not_discovered_by_convention()
{
var modelBuilder = CreateModelBuilder();
diff --git a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs
index d9429d73577..79344e7cb49 100644
--- a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs
@@ -4095,7 +4095,7 @@ public virtual void Navigation_properties_can_set_access_mode()
}
[ConditionalFact]
- public virtual void Navigation_to_shared_type_is_no_discovered_by_convention()
+ public virtual void Navigation_to_shared_type_is_not_discovered_by_convention()
{
var modelBuilder = CreateModelBuilder();
diff --git a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
index f8cdfbe95d9..e0f70cbdb64 100644
--- a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
@@ -504,7 +504,7 @@ public virtual void Can_configure_one_to_one_relationship_from_an_owned_type_col
Assert.Null(foreignKey.PrincipalToDependent);
Assert.NotEqual(ownership1.Properties.Single().Name, foreignKey.Properties.Single().Name);
Assert.Equal(5, model.GetEntityTypes().Count());
- Assert.Equal(2, model.GetEntityTypes(typeof(Order)).Count);
+ Assert.Equal(2, model.GetEntityTypes(typeof(Order)).Count());
Assert.Equal(2, ownership1.DeclaringEntityType.GetForeignKeys().Count());
Assert.Equal(2, model.GetEntityTypes().Count(e => e.ClrType == typeof(Order)));
@@ -786,8 +786,8 @@ public virtual void Can_configure_owned_type_collection_with_one_call()
nameof(SpecialOrder.SpecialOrderId), specialOwnership.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name);
Assert.Equal(9, modelBuilder.Model.GetEntityTypes().Count());
- Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count);
- Assert.Equal(7, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasDefiningNavigation()));
+ Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count());
+ Assert.Equal(7, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasSharedClrType));
Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => e.IsOwned()));
var conventionModel = (IConventionModel)modelBuilder.Model;
@@ -834,8 +834,9 @@ public virtual void Can_configure_owned_type_collection_with_one_call_afterwards
nameof(SpecialOrder.SpecialOrderId), specialOwnership.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name);
Assert.Equal(9, modelBuilder.Model.GetEntityTypes().Count());
- Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count);
- Assert.Equal(7, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasDefiningNavigation()));
+ Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count());
+ // SpecialOrder and Address are only used once, but once they are made shared they don't revert to non-shared
+ Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasSharedClrType));
Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => e.IsOwned()));
var conventionModel = (IConventionModel)modelBuilder.Model;
@@ -1286,7 +1287,7 @@ public virtual void Can_configure_self_ownership()
.ForeignKey;
var selfOwnership = bookLabelOwnership.DeclaringEntityType.FindNavigation(nameof(BookLabel.AnotherBookLabel)).ForeignKey;
Assert.NotSame(selfOwnership.PrincipalEntityType, selfOwnership.DeclaringEntityType);
- Assert.Equal(selfOwnership.PrincipalEntityType.Name, selfOwnership.DeclaringEntityType.Name);
+ Assert.Equal(selfOwnership.PrincipalEntityType.ClrType, selfOwnership.DeclaringEntityType.ClrType);
Assert.True(selfOwnership.IsOwnership);
Assert.Equal(1, model.GetEntityTypes().Count(e => e.ClrType == typeof(BookLabel)));
Assert.Equal(2, model.GetEntityTypes().Count(e => e.ClrType == typeof(AnotherBookLabel)));
@@ -1356,8 +1357,7 @@ public virtual void Configuring_base_type_as_owned_throws()
Assert.Equal(
CoreStrings.ClashingNonOwnedDerivedEntityType(nameof(BookLabel), nameof(AnotherBookLabel)),
Assert.Throws(
- () =>
- modelBuilder.Entity().OwnsOne(c => c.Label)).Message);
+ () => modelBuilder.Entity().OwnsOne(c => c.Label)).Message);
}
[ConditionalFact]
@@ -1595,36 +1595,6 @@ public virtual void Shared_type_used_as_owned_type_throws_for_same_name()
b.OwnsMany("Shared1", e => e.Collection)).Message);
});
}
-
- [ConditionalFact]
- public virtual void Cannot_add_shared_type_with_same_clr_type_as_weak_entity_type()
- {
- var modelBuilder = CreateModelBuilder();
-
- modelBuilder.Entity(
- b =>
- {
- b.OwnsOne(e => e.Bill1);
- b.OwnsOne(e => e.Bill2);
- });
-
- Assert.Equal(
- CoreStrings.ClashingNonSharedType("Shared1", typeof(BillingDetail).DisplayName()),
- Assert.Throws(
- () => modelBuilder.SharedTypeEntity("Shared1")).Message);
- }
-
- [ConditionalFact]
- public virtual void Cannot_add_owned_type_with_same_clr_type_as_shared_type_entity_type()
- {
- var modelBuilder = CreateModelBuilder();
- var entityTypeBuilder = modelBuilder.Entity();
-
- Assert.Equal(
- CoreStrings.ClashingSharedType(typeof(Dictionary).DisplayName()),
- Assert.Throws(
- () => entityTypeBuilder.OwnsOne(e => e.Reference)).Message);
- }
}
}
}
diff --git a/test/EFCore.Tests/ModelBuilding/ShadowEntityTypeTest.cs b/test/EFCore.Tests/ModelBuilding/ShadowEntityTypeTest.cs
index 19cdec10423..1f07402c917 100644
--- a/test/EFCore.Tests/ModelBuilding/ShadowEntityTypeTest.cs
+++ b/test/EFCore.Tests/ModelBuilding/ShadowEntityTypeTest.cs
@@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding
public class ShadowEntityTypeTest
{
[ConditionalFact]
- public virtual void Can_create_two_shadow_weak_owned_types()
+ public virtual void Can_create_two_shadow_owned_types()
{
var modelBuilder = CreateModelBuilder();
@@ -62,11 +62,11 @@ public virtual void Can_create_two_shadow_weak_owned_types()
Assert.Equal(
ownership1.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name,
ownership2.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name);
- Assert.Equal(2, model.GetEntityTypes().Count(e => e.Name == "CustomerDetails"));
+ Assert.Equal(2, model.GetEntityTypes().Count(e => e.ShortName() == "CustomerDetails"));
}
[ConditionalFact]
- public virtual void Can_create_One_to_One_shadow_navigations_between_shadow_entity_types()
+ public virtual void Can_create_one_to_one_shadow_navigations_between_shadow_entity_types()
{
var modelBuilder = CreateModelBuilder();
var foreignKey = modelBuilder.Entity("Order")
@@ -85,7 +85,7 @@ public virtual void Can_create_One_to_One_shadow_navigations_between_shadow_enti
}
[ConditionalFact]
- public virtual void Can_create_One_to_Many_shadow_navigations_between_shadow_entity_types()
+ public virtual void Can_create_one_to_many_shadow_navigations_between_shadow_entity_types()
{
var modelBuilder = CreateModelBuilder();
var foreignKey = modelBuilder.Entity("Order")