From 19d6f7a264bbdcbaa946bee2ad01f560fd791a6a Mon Sep 17 00:00:00 2001 From: Andriy Svyryd Date: Thu, 17 Sep 2020 10:32:58 -0700 Subject: [PATCH] Improve exception messages Part of #7201 Fixes #20951 --- .../Properties/ProxiesStrings.Designer.cs | 2 +- .../Properties/ProxiesStrings.resx | 2 +- .../Properties/RelationalStrings.Designer.cs | 10 +- .../Properties/RelationalStrings.resx | 10 +- .../Properties/SqlServerStrings.Designer.cs | 2 +- .../Properties/SqlServerStrings.resx | 2 +- .../Properties/SqliteNTSStrings.Designer.cs | 2 +- .../Properties/SqliteNTSStrings.resx | 2 +- src/EFCore/ChangeTracking/EntityEntry.cs | 2 +- src/EFCore/Infrastructure/ModelValidator.cs | 12 +- src/EFCore/Internal/InternalDbSet.cs | 4 +- .../ForeignKeyAttributeConvention.cs | 5 +- .../InversePropertyAttributeConvention.cs | 4 +- .../Conventions/KeyAttributeConvention.cs | 3 +- src/EFCore/Metadata/Internal/EntityType.cs | 10 +- src/EFCore/Metadata/Internal/ForeignKey.cs | 4 +- .../Metadata/Internal/ForeignKeyExtensions.cs | 2 + .../Metadata/Internal/SkipNavigation.cs | 4 +- src/EFCore/Properties/CoreStrings.Designer.cs | 310 +++++++++--------- src/EFCore/Properties/CoreStrings.resx | 174 +++++----- .../RelationalModelValidatorTest.cs | 2 +- .../Infrastructure/ModelValidatorTest.cs | 6 +- .../NavigationAttributeConventionTest.cs | 4 +- .../PropertyAttributeConventionTest.cs | 3 +- .../Metadata/Internal/ForeignKeyTest.cs | 12 +- .../Internal/InternalEntityTypeBuilderTest.cs | 5 +- .../Metadata/Internal/SkipNavigationTest.cs | 6 +- .../ModelBuilding/OneToOneTestBase.cs | 6 +- 28 files changed, 319 insertions(+), 291 deletions(-) diff --git a/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs b/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs index 3eaa9397138..cd598418d75 100644 --- a/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs +++ b/src/EFCore.Proxies/Properties/ProxiesStrings.Designer.cs @@ -27,7 +27,7 @@ public static string DictionaryCannotBeProxied([CanBeNull] object dictionaryType dictionaryType, entityType, interfaceType); /// - /// The type '{clrType}' is configured as a shared-type entity type, but the entity type name is not known. Ensure that CreateProxy is called on a DbSet created specifically for the shared-type entity type through use of a `DbContext.Set` overload that accepts an entity type name. + /// The type '{clrType}' is configured as a shared-type entity type, but the entity type name is not known. Ensure that CreateProxy is called on a DbSet created specifically for the shared-type entity type through use of a 'DbContext.Set' overload that accepts an entity type name. /// public static string EntityTypeNotFoundShared([CanBeNull] object clrType) => string.Format( diff --git a/src/EFCore.Proxies/Properties/ProxiesStrings.resx b/src/EFCore.Proxies/Properties/ProxiesStrings.resx index c2bb4f2e932..f6c2654247f 100644 --- a/src/EFCore.Proxies/Properties/ProxiesStrings.resx +++ b/src/EFCore.Proxies/Properties/ProxiesStrings.resx @@ -121,7 +121,7 @@ The type '{dictionaryType}' used for shared entity type '{entityType}' is not suitable for use as a change-tracking proxy because its indexer property is not virtual. Consider using an implementation of '{interfaceType}' that allows overriding of the indexer. - The type '{clrType}' is configured as a shared-type entity type, but the entity type name is not known. Ensure that CreateProxy is called on a DbSet created specifically for the shared-type entity type through use of a `DbContext.Set` overload that accepts an entity type name. + The type '{clrType}' is configured as a shared-type entity type, but the entity type name is not known. Ensure that CreateProxy is called on a DbSet created specifically for the shared-type entity type through use of a 'DbContext.Set' overload that accepts an entity type name. 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. diff --git a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs index 2c1515f3fdb..1baf1b0ecb9 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs +++ b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs @@ -147,7 +147,7 @@ public static string DataOperationNoTable([CanBeNull] object table) table); /// - /// The provided DbFunction expression '{expression}' is invalid. The expression should be a lambda expression containing a single method call to the target static method. Default values can be provided as arguments if required. E.g. () => SomeClass.SomeMethod(null, 0) + /// The provided DbFunction expression '{expression}' is invalid. The expression should be a lambda expression containing a single method call to the target static method. Default values can be provided as arguments if required. E.g. '() => SomeClass.SomeMethod(null, 0)'. /// public static string DbFunctionExpressionIsNotMethodCall([CanBeNull] object expression) => string.Format( @@ -380,7 +380,7 @@ public static string DuplicateColumnNameScaleMismatch([CanBeNull] object entityT entityType1, property1, entityType2, property2, columnName, table, scale1, scale2); /// - /// '{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}' but are configured with different unicode configuration + /// '{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}' but are configured with different unicode configuration. /// public static string DuplicateColumnNameUnicodenessMismatch([CanBeNull] object entityType1, [CanBeNull] object property1, [CanBeNull] object entityType2, [CanBeNull] object property2, [CanBeNull] object columnName, [CanBeNull] object table) => string.Format( @@ -652,7 +652,7 @@ public static string InvalidDerivedTypeInEntityProjection([CanBeNull] object der derivedType, entityType); /// - /// The grouping key '{keySelector}' is of type '{keyType}' which is not valid key. + /// The grouping key '{keySelector}' is of type '{keyType}' which is not valid key. /// public static string InvalidKeySelectorForGroupBy([CanBeNull] object keySelector, [CanBeNull] object keyType) => string.Format( @@ -668,7 +668,7 @@ public static string InvalidMappedFunctionDerivedType([CanBeNull] object entityT entityType, functionName, baseEntityType); /// - /// The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' with return type '{returnType}'. Ensure that mapped function returns `IQueryable<{clrType}>`. + /// The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' with return type '{returnType}'. Ensure that mapped function returns 'IQueryable<{clrType}>'. /// public static string InvalidMappedFunctionUnmatchedReturn([CanBeNull] object entityType, [CanBeNull] object functionName, [CanBeNull] object returnType, [CanBeNull] object clrType) => string.Format( @@ -1955,7 +1955,7 @@ public static EventDefinition LogMigrationAttributeMissingWarning([NotNu } /// - /// Compiling a query which loads related collections for more than one collection navigation either via 'Include' or through projection but no 'QuerySplittingBehavior' has been configured. By default Entity Framework will use 'QuerySplittingBehavior.SingleQuery' which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))' + /// Compiling a query which loads related collections for more than one collection navigation either via 'Include' or through projection but no 'QuerySplittingBehavior' has been configured. By default Entity Framework will use 'QuerySplittingBehavior.SingleQuery' which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))'. /// public static EventDefinition LogMultipleCollectionIncludeWarning([NotNull] IDiagnosticsLogger logger) { diff --git a/src/EFCore.Relational/Properties/RelationalStrings.resx b/src/EFCore.Relational/Properties/RelationalStrings.resx index 6833a3a2df8..e2bdd4039b3 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.resx +++ b/src/EFCore.Relational/Properties/RelationalStrings.resx @@ -169,7 +169,7 @@ There is no entity type mapped to the table '{table}' used in a data operation. Either add the corresponding entity type to the model or specify the column types in the data operation. - The provided DbFunction expression '{expression}' is invalid. The expression should be a lambda expression containing a single method call to the target static method. Default values can be provided as arguments if required. E.g. () => SomeClass.SomeMethod(null, 0) + The provided DbFunction expression '{expression}' is invalid. The expression should be a lambda expression containing a single method call to the target static method. Default values can be provided as arguments if required. E.g. '() => SomeClass.SomeMethod(null, 0)'. The DbFunction '{function}' is generic. Mapping generic methods as a DbFunction is not supported. @@ -257,7 +257,7 @@ '{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}' but are configured with different scale ('{scale1}' and '{scale2}'). - '{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}' but are configured with different unicode configuration + '{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}' but are configured with different unicode configuration. The foreign keys {foreignKeyProperties1} on '{entityType1}' and {foreignKeyProperties2} on '{entityType2}' are both mapped to '{table}.{foreignKeyName}' but use different columns ({columnNames1} and {columnNames2}). @@ -362,13 +362,13 @@ The specified entity type '{derivedType}' is not derived from '{entityType}'. - The grouping key '{keySelector}' is of type '{keyType}' which is not valid key. + The grouping key '{keySelector}' is of type '{keyType}' which is not valid key. The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' and it's derived from '{baseEntityType}'. Derived entity types cannot be mapped to a function. - The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' with return type '{returnType}'. Ensure that mapped function returns `IQueryable<{clrType}>`. + The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' with return type '{returnType}'. Ensure that mapped function returns 'IQueryable<{clrType}>'. The entity type '{entityType}' is mapped to the DbFunction named '{functionName}' with parameters {parameters}. Ensure that mapped function doesn't have any parameters. @@ -514,7 +514,7 @@ Warning RelationalEventId.MigrationAttributeMissingWarning string - Compiling a query which loads related collections for more than one collection navigation either via 'Include' or through projection but no 'QuerySplittingBehavior' has been configured. By default Entity Framework will use 'QuerySplittingBehavior.SingleQuery' which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))' + Compiling a query which loads related collections for more than one collection navigation either via 'Include' or through projection but no 'QuerySplittingBehavior' has been configured. By default Entity Framework will use 'QuerySplittingBehavior.SingleQuery' which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))'. Warning RelationalEventId.MultipleCollectionIncludeWarning diff --git a/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs b/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs index 365da24ea07..a27dd034ead 100644 --- a/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs +++ b/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs @@ -332,7 +332,7 @@ public static EventDefinition LogDefaultDecimalTypeColumn([NotNu } /// - /// Found column with table: {tableName}, column name: {columnName}, ordinal: {ordinal}, data type: {dataType}, maximum length: {maxLength}, precision: {precision}, scale: {scale}, nullable: {nullable}, identity: {identity}, default value: {defaultValue}, computed value: {computedValue}, computed value is stored: {stored} + /// Found column with table: {tableName}, column name: {columnName}, ordinal: {ordinal}, data type: {dataType}, maximum length: {maxLength}, precision: {precision}, scale: {scale}, nullable: {nullable}, identity: {identity}, default value: {defaultValue}, computed value: {computedValue}, computed value is stored: {stored}. /// public static FallbackEventDefinition LogFoundColumn([NotNull] IDiagnosticsLogger logger) { diff --git a/src/EFCore.SqlServer/Properties/SqlServerStrings.resx b/src/EFCore.SqlServer/Properties/SqlServerStrings.resx index 2b60ac5ec04..c87874c0757 100644 --- a/src/EFCore.SqlServer/Properties/SqlServerStrings.resx +++ b/src/EFCore.SqlServer/Properties/SqlServerStrings.resx @@ -194,7 +194,7 @@ Warning SqlServerEventId.DecimalTypeDefaultWarning string string - Found column with table: {tableName}, column name: {columnName}, ordinal: {ordinal}, data type: {dataType}, maximum length: {maxLength}, precision: {precision}, scale: {scale}, nullable: {nullable}, identity: {identity}, default value: {defaultValue}, computed value: {computedValue}, computed value is stored: {stored} + Found column with table: {tableName}, column name: {columnName}, ordinal: {ordinal}, data type: {dataType}, maximum length: {maxLength}, precision: {precision}, scale: {scale}, nullable: {nullable}, identity: {identity}, default value: {defaultValue}, computed value: {computedValue}, computed value is stored: {stored}. Debug SqlServerEventId.ColumnFound string string int string int int int bool bool string string bool? diff --git a/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.Designer.cs b/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.Designer.cs index 4546bf60ac5..2bfeab01559 100644 --- a/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.Designer.cs +++ b/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.Designer.cs @@ -19,7 +19,7 @@ private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.EntityFrameworkCore.Sqlite.Properties.SqliteNTSStrings", typeof(SqliteNTSStrings).Assembly); /// - /// Invalid geometry type: {storeType} + /// Invalid geometry type: {storeType}. /// public static string InvalidGeometryType([CanBeNull] object storeType) => string.Format( diff --git a/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.resx b/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.resx index 38dc6001d31..d3a08ff171d 100644 --- a/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.resx +++ b/src/EFCore.Sqlite.NTS/Properties/SqliteNTSStrings.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Invalid geometry type: {storeType} + Invalid geometry type: {storeType}. UseNetTopologySuite requires AddEntityFrameworkSqliteNetTopologySuite to be called on the internal service provider used. diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs index 16d917f2ce7..314e4f88710 100644 --- a/src/EFCore/ChangeTracking/EntityEntry.cs +++ b/src/EFCore/ChangeTracking/EntityEntry.cs @@ -87,7 +87,7 @@ public virtual EntityState State if (value < 0 || (int)value > _maxEntityState) { - throw new ArgumentException(CoreStrings.InvalidEnumValue(nameof(value), typeof(EntityState))); + throw new ArgumentException(CoreStrings.InvalidEnumValue(value, nameof(value), typeof(EntityState))); } InternalEntry.SetEntityState(value); diff --git a/src/EFCore/Infrastructure/ModelValidator.cs b/src/EFCore/Infrastructure/ModelValidator.cs index a6732b50921..5d96b3a3996 100644 --- a/src/EFCore/Infrastructure/ModelValidator.cs +++ b/src/EFCore/Infrastructure/ModelValidator.cs @@ -491,7 +491,9 @@ protected virtual void ValidateNoCycles( if (!reachableTypes.Add(principalType)) { - throw new InvalidOperationException(CoreStrings.IdentifyingRelationshipCycle(rootEntityType.DisplayName())); + throw new InvalidOperationException(CoreStrings.IdentifyingRelationshipCycle( + rootEntityType.DisplayName(), + primaryKey.Properties.Format())); } typesToValidate.Enqueue(principalType); @@ -578,7 +580,8 @@ private void ValidateClrInheritance( if (!baseEntityType.IsAssignableFrom(entityType)) { throw new InvalidOperationException( - CoreStrings.InconsistentInheritance(entityType.DisplayName(), baseEntityType.DisplayName())); + CoreStrings.InconsistentInheritance( + entityType.DisplayName(), entityType.BaseType.DisplayName(), baseEntityType.DisplayName())); } break; @@ -714,7 +717,10 @@ protected virtual void ValidateOwnership( var ownerships = entityType.GetForeignKeys().Where(fk => fk.IsOwnership).ToList(); if (ownerships.Count > 1) { - throw new InvalidOperationException(CoreStrings.MultipleOwnerships(entityType.DisplayName())); + throw new InvalidOperationException(CoreStrings.MultipleOwnerships( + entityType.DisplayName(), + string.Join(", ", + ownerships.Select(o => $"'{o.PrincipalEntityType.DisplayName()}.{o.PrincipalToDependent?.Name}'")))); } if (ownerships.Count == 1) diff --git a/src/EFCore/Internal/InternalDbSet.cs b/src/EFCore/Internal/InternalDbSet.cs index a0d228d98ad..f7bb7b25b26 100644 --- a/src/EFCore/Internal/InternalDbSet.cs +++ b/src/EFCore/Internal/InternalDbSet.cs @@ -91,9 +91,11 @@ public override IEntityType EntityType if (_entityType.IsOwned()) { + var message = CoreStrings.InvalidSetTypeOwned( + _entityType.DisplayName(), _entityType.FindOwnership().PrincipalEntityType.DisplayName()); _entityType = null; - throw new InvalidOperationException(CoreStrings.InvalidSetTypeOwned(typeof(TEntity).ShortDisplayName())); + throw new InvalidOperationException(message); } if (_entityType.ClrType != typeof(TEntity)) diff --git a/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs index 474a3e2a4e5..b31f6e4c269 100644 --- a/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs @@ -417,7 +417,10 @@ private static IReadOnlyList FindCandidateDependentPropertiesThroughNavi if (attribute?.Name == navigationFkAttribute.Name) { throw new InvalidOperationException( - CoreStrings.MultipleNavigationsSameFk(navigation.DeclaringEntityType.DisplayName(), attribute.Name)); + CoreStrings.MultipleNavigationsSameFk( + navigation.DeclaringEntityType.DisplayName(), + attribute.Name, + $"'{navigation.Name}', '{propertyInfo.Name}'")); } } diff --git a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs index a845587813e..5102fb88201 100644 --- a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs @@ -100,10 +100,8 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( { throw new InvalidOperationException( CoreStrings.SelfReferencingNavigationWithInverseProperty( - navigationMemberInfo.Name, entityType.DisplayName(), - navigationMemberInfo.Name, - entityType.DisplayName())); + navigationMemberInfo.Name)); } // Check for InversePropertyAttribute on the inverse navigation to verify that it matches. diff --git a/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs index 5d95266e887..4fd03ee87c0 100644 --- a/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs @@ -119,7 +119,8 @@ public virtual void ProcessModelFinalizing( && Attribute.IsDefined(memberInfo, typeof(KeyAttribute), inherit: true)) { throw new InvalidOperationException( - CoreStrings.KeyAttributeOnDerivedEntity(entityType.DisplayName(), declaredProperty.Name)); + CoreStrings.KeyAttributeOnDerivedEntity( + entityType.DisplayName(), declaredProperty.Name, entityType.GetRootType().DisplayName())); } } } diff --git a/src/EFCore/Metadata/Internal/EntityType.cs b/src/EFCore/Metadata/Internal/EntityType.cs index 7233917b70e..722e714dd6f 100644 --- a/src/EFCore/Metadata/Internal/EntityType.cs +++ b/src/EFCore/Metadata/Internal/EntityType.cs @@ -247,9 +247,10 @@ public virtual bool IsKeyless CoreStrings.DerivedEntityTypeHasNoKey(this.DisplayName(), RootType().DisplayName())); } - if (_keys.Any()) + if (_keys.Count != 0) { - throw new InvalidOperationException(CoreStrings.KeylessTypeExistingKey(this.DisplayName())); + throw new InvalidOperationException(CoreStrings.KeylessTypeExistingKey( + this.DisplayName(), _keys.First().Value.Properties.Format())); } } @@ -1891,9 +1892,10 @@ public virtual SkipNavigation RemoveSkipNavigation([NotNull] SkipNavigation navi { throw new InvalidOperationException( CoreStrings.SkipNavigationInUseBySkipNavigation( + navigation.DeclaringEntityType.DisplayName(), navigation.Name, - navigation.Inverse.Name, - navigation.Inverse.DeclaringEntityType.DisplayName())); + navigation.Inverse.DeclaringEntityType.DisplayName(), + navigation.Inverse.Name)); } var removed = _skipNavigations.Remove(navigation.Name); diff --git a/src/EFCore/Metadata/Internal/ForeignKey.cs b/src/EFCore/Metadata/Internal/ForeignKey.cs index 81dac6bacd2..1d22fe254db 100644 --- a/src/EFCore/Metadata/Internal/ForeignKey.cs +++ b/src/EFCore/Metadata/Internal/ForeignKey.cs @@ -1351,9 +1351,9 @@ public static bool AreCompatible( { throw new InvalidOperationException( CoreStrings.ForeignKeyTypeMismatch( - dependentProperties.Format(), + dependentProperties.Format(includeTypes: true), dependentEntityType.DisplayName(), - principalProperties.Format(), + principalProperties.Format(includeTypes: true), principalEntityType.DisplayName())); } diff --git a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs index f7872899f2b..7f16aa8ce67 100644 --- a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs +++ b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs @@ -171,6 +171,7 @@ private static IEnumerable FindNavigations( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// + [Obsolete] public static IEntityType ResolveOtherEntityTypeInHierarchy( [NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) @@ -207,6 +208,7 @@ public static IEntityType ResolveOtherEntityTypeInHierarchy( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// + [Obsolete] public static IEntityType ResolveEntityTypeInHierarchy([NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) { if (!foreignKey.DeclaringEntityType.IsAssignableFrom(entityType) diff --git a/src/EFCore/Metadata/Internal/SkipNavigation.cs b/src/EFCore/Metadata/Internal/SkipNavigation.cs index ad000eb5f64..ee1cb2068ac 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigation.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigation.cs @@ -185,9 +185,9 @@ public virtual ForeignKey SetForeignKey([CanBeNull] ForeignKey foreignKey, Confi { var message = IsOnDependent ? CoreStrings.SkipNavigationForeignKeyWrongDependentType( - foreignKey.Properties.Format(), Name, DeclaringEntityType.DisplayName(), expectedEntityType.DisplayName()) + foreignKey.Properties.Format(), DeclaringEntityType.DisplayName(), Name, expectedEntityType.DisplayName()) : CoreStrings.SkipNavigationForeignKeyWrongPrincipalType( - foreignKey.Properties.Format(), Name, DeclaringEntityType.DisplayName(), expectedEntityType.DisplayName()); + foreignKey.Properties.Format(), DeclaringEntityType.DisplayName(), Name, expectedEntityType.DisplayName()); throw new InvalidOperationException(message); } diff --git a/src/EFCore/Properties/CoreStrings.Designer.cs b/src/EFCore/Properties/CoreStrings.Designer.cs index afe9c065ba6..dd24a5be175 100644 --- a/src/EFCore/Properties/CoreStrings.Designer.cs +++ b/src/EFCore/Properties/CoreStrings.Designer.cs @@ -309,7 +309,7 @@ public static string ClashingNonOwnedEntityType([CanBeNull] object entityType) entityType); /// - /// The shared type entity type '{entityType}' with CLR type '{type}' cannot be added to the model because a non-shared entity type with the same CLR type already exists. + /// The shared-type entity type '{entityType}' with CLR type '{type}' cannot be added to the model because a non-shared entity type with the same CLR type already exists. /// public static string ClashingNonSharedType([CanBeNull] object entityType, [CanBeNull] object type) => string.Format( @@ -381,7 +381,7 @@ public static string ClrPropertyOnShadowEntity([CanBeNull] object property, [Can property, entityType); /// - /// The property '{1_entityType}.{0_property}' is being accessed using '{collectionMethod}', but is defined in the model as a non-collection, reference navigation. Use '{referenceMethod}' to access reference navigation properties. + /// The property '{1_entityType}.{0_property}' is being accessed using '{collectionMethod}', but is defined in the model as a non-collection, reference navigation. Use '{referenceMethod}' to access reference navigations. /// public static string CollectionIsReference([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object collectionMethod, [CanBeNull] object referenceMethod) => string.Format( @@ -443,7 +443,7 @@ public static string ConflictingPropertyOrNavigation([CanBeNull] object member, member, entityType, conflictingEntityType); /// - /// Cannot create a relationship between '{newPrincipalNavigationSpecification}' and '{newDependentNavigationSpecification}' because a relationship already exists between '{existingPrincipalNavigationSpecification}' and '{existingDependentNavigationSpecification}'. Navigation properties can only participate in a single relationship. If you want to override an existing relationship call 'Ignore' on the navigation '{newDependentNavigationSpecification}' first in 'OnModelCreating'. + /// Cannot create a relationship between '{newPrincipalNavigationSpecification}' and '{newDependentNavigationSpecification}' because a relationship already exists between '{existingPrincipalNavigationSpecification}' and '{existingDependentNavigationSpecification}'. Navigations can only participate in a single relationship. If you want to override an existing relationship call 'Ignore' on the navigation '{newDependentNavigationSpecification}' first in 'OnModelCreating'. /// public static string ConflictingRelationshipNavigation([CanBeNull] object newPrincipalNavigationSpecification, [CanBeNull] object newDependentNavigationSpecification, [CanBeNull] object existingPrincipalNavigationSpecification, [CanBeNull] object existingDependentNavigationSpecification) => string.Format( @@ -803,7 +803,7 @@ public static string EntityTypeNotInRelationshipStrict([CanBeNull] object entity entityType, dependentType, principalType); /// - /// The specified entity types '{invalidDependentType}' and '{invalidPrincipalType}' are invalid. They should be '{dependentType}' and '{principalType}', or entity types in the same hierarchy. + /// The provided entity types '{invalidDependentType}' and '{invalidPrincipalType}' are invalid. Specify '{dependentType}' and '{principalType}', or entity types in the same hierarchy. /// public static string EntityTypesNotInRelationship([CanBeNull] object invalidDependentType, [CanBeNull] object invalidPrincipalType, [CanBeNull] object dependentType, [CanBeNull] object principalType) => string.Format( @@ -847,7 +847,7 @@ public static string ExpressionParameterizationExceptionSensitive([CanBeNull] ob expression); /// - /// The specified field '{field}' cannot be used for the property '{entityType}.{property}' because it does not match the property name. + /// The specified field '{field}' cannot be used for the property '{entityType}.{property}' because it does not match the property name. Entity type properties that aren't associated with a CLR property must match the field name exactly. /// public static string FieldNameMismatch([CanBeNull] object field, [CanBeNull] object entityType, [CanBeNull] object property) => string.Format( @@ -855,7 +855,7 @@ public static string FieldNameMismatch([CanBeNull] object field, [CanBeNull] obj field, entityType, property); /// - /// Entity type '{entityType}' is defined with a single key property, but {valuesCount} values were passed to the 'DbSet.Find' method. + /// Entity type '{entityType}' is defined with a single key property, but {valuesCount} values were passed to the 'Find' method. /// public static string FindNotCompositeKey([CanBeNull] object entityType, [CanBeNull] object valuesCount) => string.Format( @@ -863,7 +863,7 @@ public static string FindNotCompositeKey([CanBeNull] object entityType, [CanBeNu entityType, valuesCount); /// - /// Entity type '{entityType}' is defined with a {propertiesCount}-part composite key, but {valuesCount} values were passed to the 'DbSet.Find' method. + /// Entity type '{entityType}' is defined with a {propertiesCount}-part composite key, but {valuesCount} values were passed to the 'Find' method. /// public static string FindValueCountMismatch([CanBeNull] object entityType, [CanBeNull] object propertiesCount, [CanBeNull] object valuesCount) => string.Format( @@ -887,7 +887,7 @@ public static string FkAttributeOnNonUniquePrincipal([CanBeNull] object navigati navigation, principalType, dependentType); /// - /// The [ForeignKey] attributes on property '{property}' and navigation '{navigation}' in entity type '{entityType}' do not point at each other. The value of the [ForeignKey] attribute on the property should be navigation name, and the value of the [ForeignKey] attribute on the navigation should be the foreign key property name. + /// The [ForeignKey] attributes on property '{property}' and navigation '{navigation}' in entity type '{entityType}' do not point at each other. Make sure the value of the [ForeignKey] attribute on the property matches the navigation name, and the value of the [ForeignKey] attribute on the navigation matches the foreign key property name or remove one of them. /// public static string FkAttributeOnPropertyNavigationMismatch([CanBeNull] object property, [CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -903,20 +903,20 @@ public static string FkAttributeOnSkipNavigation([CanBeNull] object entityType, entityType, navigation); /// - /// The number of properties specified for the foreign key {foreignKeyProperties} on entity type '{dependentType}' does not match the number of properties in the principal key {principalKey} on entity type '{principalType}'. + /// The number of properties specified for the foreign key {foreignKeyProperties} on entity type '{dependentType}' does not match the number of properties in the principal key {principalKeyProperties} on entity type '{principalType}'. /// - public static string ForeignKeyCountMismatch([CanBeNull] object foreignKeyProperties, [CanBeNull] object dependentType, [CanBeNull] object principalKey, [CanBeNull] object principalType) + public static string ForeignKeyCountMismatch([CanBeNull] object foreignKeyProperties, [CanBeNull] object dependentType, [CanBeNull] object principalKeyProperties, [CanBeNull] object principalType) => string.Format( - GetString("ForeignKeyCountMismatch", nameof(foreignKeyProperties), nameof(dependentType), nameof(principalKey), nameof(principalType)), - foreignKeyProperties, dependentType, principalKey, principalType); + GetString("ForeignKeyCountMismatch", nameof(foreignKeyProperties), nameof(dependentType), nameof(principalKeyProperties), nameof(principalType)), + foreignKeyProperties, dependentType, principalKeyProperties, principalType); /// - /// Cannot remove the foreign key {foreigKey} from entity type '{entityType}' because it is referenced by a skip navigation '{navigation}' on entity type '{navigationEntityType}'. All referencing skip navigation must be removed before the referenced foreign key can be removed. + /// Cannot remove the foreign key {foreignKeyProperties} from entity type '{entityType}' because it is referenced by a skip navigation '{navigation}' on entity type '{navigationEntityType}'. All referencing skip navigations must be removed before the referenced foreign key can be removed. /// - public static string ForeignKeyInUseSkipNavigation([CanBeNull] object foreigKey, [CanBeNull] object entityType, [CanBeNull] object navigation, [CanBeNull] object navigationEntityType) + public static string ForeignKeyInUseSkipNavigation([CanBeNull] object foreignKeyProperties, [CanBeNull] object entityType, [CanBeNull] object navigation, [CanBeNull] object navigationEntityType) => string.Format( - GetString("ForeignKeyInUseSkipNavigation", nameof(foreigKey), nameof(entityType), nameof(navigation), nameof(navigationEntityType)), - foreigKey, entityType, navigation, navigationEntityType); + GetString("ForeignKeyInUseSkipNavigation", nameof(foreignKeyProperties), nameof(entityType), nameof(navigation), nameof(navigationEntityType)), + foreignKeyProperties, entityType, navigation, navigationEntityType); /// /// The specified foreign key properties {foreignKeyProperties} are not declared on the entity type '{entityType}'. Ensure that foreign key properties are declared on the target entity type. @@ -927,7 +927,7 @@ public static string ForeignKeyPropertiesWrongEntity([CanBeNull] object foreignK foreignKeyProperties, entityType); /// - /// The property '{property}' cannot be part of a foreign key on '{entityType}' because it has a store-generated value and is contained in the key {keyProperties} defined on a base entity type '{baseEntityType}'. + /// The property '{property}' cannot be part of a foreign key on '{entityType}' because it has a store-generated value and is contained in the key {keyProperties} defined on a base entity type '{baseEntityType}'. Configure '{property}' with 'ValueGeneratedNever' or define the foreign key on '{entityType}' instead. /// public static string ForeignKeyPropertyInKey([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object keyProperties, [CanBeNull] object baseEntityType) => string.Format( @@ -935,12 +935,12 @@ public static string ForeignKeyPropertyInKey([CanBeNull] object property, [CanBe property, entityType, keyProperties, baseEntityType); /// - /// The provided principal entity key '{principalKey}' is not a key on the entity type '{principalEntityType}'. + /// The provided principal key {principalKeyProperties} is not a key on the entity type '{principalEntityType}'. Provide a key that's defined on the principal entity type. /// - public static string ForeignKeyReferencedEntityKeyMismatch([CanBeNull] object principalKey, [CanBeNull] object principalEntityType) + public static string ForeignKeyReferencedEntityKeyMismatch([CanBeNull] object principalKeyProperties, [CanBeNull] object principalEntityType) => string.Format( - GetString("ForeignKeyReferencedEntityKeyMismatch", nameof(principalKey), nameof(principalEntityType)), - principalKey, principalEntityType); + GetString("ForeignKeyReferencedEntityKeyMismatch", nameof(principalKeyProperties), nameof(principalEntityType)), + principalKeyProperties, principalEntityType); /// /// The foreign keys on entity type '{dependentType}' cannot target the same entity type because it is a weak entity type. @@ -951,12 +951,12 @@ public static string ForeignKeySelfReferencingDependentEntityType([CanBeNull] ob dependentType); /// - /// 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 {principalKey} on entity type '{principalType}'. + /// 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. /// - public static string ForeignKeyTypeMismatch([CanBeNull] object foreignKeyProperties, [CanBeNull] object dependentType, [CanBeNull] object principalKey, [CanBeNull] object principalType) + public static string ForeignKeyTypeMismatch([CanBeNull] object foreignKeyProperties, [CanBeNull] object dependentType, [CanBeNull] object principalKeyProperties, [CanBeNull] object principalType) => string.Format( - GetString("ForeignKeyTypeMismatch", nameof(foreignKeyProperties), nameof(dependentType), nameof(principalKey), nameof(principalType)), - foreignKeyProperties, dependentType, principalKey, principalType); + GetString("ForeignKeyTypeMismatch", nameof(foreignKeyProperties), nameof(dependentType), nameof(principalKeyProperties), nameof(principalType)), + foreignKeyProperties, dependentType, principalKeyProperties, principalType); /// /// The foreign key {foreignKeyProperties} targeting the key {keyProperties} on '{principalType}' cannot be removed from the entity type '{entityType}' because it is defined on the entity type '{otherEntityType}'. @@ -983,7 +983,7 @@ public static string FunctionOnClient([CanBeNull] object methodName) methodName); /// - /// The edge cannot be added because the graph does not contain vertex '{vertex}'. + /// The provided edge cannot be added because the graph does not contain the vertex '{vertex}'. /// public static string GraphDoesNotContainVertex([CanBeNull] object vertex) => string.Format( @@ -991,18 +991,18 @@ public static string GraphDoesNotContainVertex([CanBeNull] object vertex) vertex); /// - /// The block size used for Hi-Lo value generation must be positive. When the Hi-Lo generator is backed by a SQL sequence this means that the sequence increment must be positive. + /// The block size used for Hi-Lo value generation is not positive. The Hi-Lo generator is usually backed by a SQL sequence and this means that the sequence increment must be positive. /// public static string HiLoBadBlockSize => GetString("HiLoBadBlockSize"); /// - /// The entity type '{entityType}' is part of a relationship cycle involving its primary key. + /// The entity type '{entityType}' is part of a relationship cycle involving its primary key {keyProperties}. This would prevent any values to be inserted without vialoating the store constraints. Review the foreign keys defined on the primary key and either remove or use other properties for at least one of them. /// - public static string IdentifyingRelationshipCycle([CanBeNull] object entityType) + public static string IdentifyingRelationshipCycle([CanBeNull] object entityType, [CanBeNull] object keyProperties) => string.Format( - GetString("IdentifyingRelationshipCycle", nameof(entityType)), - entityType); + GetString("IdentifyingRelationshipCycle", nameof(entityType), nameof(keyProperties)), + entityType, keyProperties); /// /// The instance of entity type '{entityType}' cannot be tracked because another instance with the same key value for {keyProperties} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values. @@ -1076,15 +1076,15 @@ public static string IncludeWithCycle([CanBeNull] object navigationName, [CanBeN navigationName, inverseNavigationName); /// - /// The entity type '{entityType}' should derive from '{baseEntityType}' to reflect the hierarchy of the corresponding CLR types. + /// The entity type '{entityType}' is configured as derived from '{baseEntityType}', however according to the hierarchy of the corresponding CLR types it should derive from '{clrBaseEntityType}'. Configure '{entityType}' having either '{baseEntityType}' or 'null' as the base type. /// - public static string InconsistentInheritance([CanBeNull] object entityType, [CanBeNull] object baseEntityType) + public static string InconsistentInheritance([CanBeNull] object entityType, [CanBeNull] object baseEntityType, [CanBeNull] object clrBaseEntityType) => string.Format( - GetString("InconsistentInheritance", nameof(entityType), nameof(baseEntityType)), - entityType, baseEntityType); + GetString("InconsistentInheritance", nameof(entityType), nameof(baseEntityType), nameof(clrBaseEntityType)), + entityType, baseEntityType, clrBaseEntityType); /// - /// The entity type '{ownedEntityType}' is configured as owned, but the entity type '{nonOwnedEntityType}' is not. All entity types sharing a CLR type must be configured as owned in 'OnModelCreating'. + /// 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'. /// public static string InconsistentOwnership([CanBeNull] object ownedEntityType, [CanBeNull] object nonOwnedEntityType) => string.Format( @@ -1092,12 +1092,12 @@ public static string InconsistentOwnership([CanBeNull] object ownedEntityType, [ ownedEntityType, nonOwnedEntityType); /// - /// The specified index properties {index} are not declared on the entity type '{entityType}'. Ensure that index properties are declared on the target entity type. + /// The specified index properties {indexProperties} are not declared on the entity type '{entityType}'. Ensure that index properties are declared on the target entity type. /// - public static string IndexPropertiesWrongEntity([CanBeNull] object index, [CanBeNull] object entityType) + public static string IndexPropertiesWrongEntity([CanBeNull] object indexProperties, [CanBeNull] object entityType) => string.Format( - GetString("IndexPropertiesWrongEntity", nameof(index), nameof(entityType)), - index, entityType); + GetString("IndexPropertiesWrongEntity", nameof(indexProperties), nameof(entityType)), + indexProperties, entityType); /// /// The index {indexProperties} cannot be removed from the entity type '{entityType}' because it is defined on the entity type '{otherEntityType}'. @@ -1108,7 +1108,7 @@ public static string IndexWrongType([CanBeNull] object indexProperties, [CanBeNu indexProperties, entityType, otherEntityType); /// - /// The property '{property}' cannot be ignored on entity type '{entityType}' because it's declared on the base entity type '{baseEntityType}'. To exclude this property from your model, use the [NotMapped] attribute or 'EntityTypeBuilder.Ignore' on the base type in 'OnModelCreating'. + /// The property '{property}' cannot be ignored on entity type '{entityType}' because it's declared on the base entity type '{baseEntityType}'. To exclude this property from your model, use the [NotMapped] attribute or 'Ignore' on the base type in 'OnModelCreating'. /// public static string InheritedPropertyCannotBeIgnored([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object baseEntityType) => string.Format( @@ -1116,7 +1116,7 @@ public static string InheritedPropertyCannotBeIgnored([CanBeNull] object propert property, entityType, baseEntityType); /// - /// The property '{entityType}.{navigation}' is of an interface type ('{propertyType}'). If it is a navigation, manually configure the relationship for this property by casting it to a mapped entity type. Otherwise, ignore the property using the [NotMapped] attribute or 'EntityTypeBuilder.Ignore' in 'OnModelCreating'. + /// The property '{entityType}.{navigation}' is of an interface type ('{propertyType}'). If it is a navigation, manually configure the relationship for this property by casting it to a mapped entity type. Otherwise, ignore the property using the [NotMapped] attribute or 'Ignore' in 'OnModelCreating'. /// public static string InterfacePropertyNotAdded([CanBeNull] object entityType, [CanBeNull] object navigation, [CanBeNull] object propertyType) => string.Format( @@ -1126,6 +1126,7 @@ public static string InterfacePropertyNotAdded([CanBeNull] object entityType, [C /// /// The entity type related to '{entityType}' cannot be determined because the specified foreign key {foreignKeyProperties} references entity type '{principalEntityType}', which is in the same hierarchy as the entity type which is declared on '{dependentEntityType}'. /// + [Obsolete] public static string IntraHierarchicalAmbiguousTargetEntityType([CanBeNull] object entityType, [CanBeNull] object foreignKeyProperties, [CanBeNull] object principalEntityType, [CanBeNull] object dependentEntityType) => string.Format( GetString("IntraHierarchicalAmbiguousTargetEntityType", nameof(entityType), nameof(foreignKeyProperties), nameof(principalEntityType), nameof(dependentEntityType)), @@ -1148,12 +1149,12 @@ public static string InvalidEntityType([CanBeNull] object type) type); /// - /// The value provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'. + /// The value '{value}' provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'. /// - public static string InvalidEnumValue([CanBeNull] object argumentName, [CanBeNull] object enumType) + public static string InvalidEnumValue([CanBeNull] object value, [CanBeNull] object argumentName, [CanBeNull] object enumType) => string.Format( - GetString("InvalidEnumValue", nameof(argumentName), nameof(enumType)), - argumentName, enumType); + GetString("InvalidEnumValue", nameof(value), nameof(argumentName), nameof(enumType)), + value, argumentName, enumType); /// /// The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see http://go.microsoft.com/fwlink/?LinkID=746393. @@ -1220,7 +1221,7 @@ public static string InvalidPropertyExpression([CanBeNull] object expression) expression); /// - /// The property list specified using [ForeignKey] attribute on navigation '{1_entityType}.{0_navigation}' is incorrect. The attribute value should be comma-separated list of property names. + /// The property list specified using [ForeignKey] attribute on navigation '{1_entityType}.{0_navigation}' is incorrect. Provide a comma-separated list of property names. /// public static string InvalidPropertyListOnNavigation([CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -1228,7 +1229,7 @@ public static string InvalidPropertyListOnNavigation([CanBeNull] object navigati navigation, entityType); /// - /// An invalid relationship has been specified using the [InverseProperty] and [ForeignKey] attributes. The navigations '{1_entityType}.{0_navigation}' and '{3_referencedEntityType}.{2_referencedNavigation}' are related by the [InverseProperty] attribute, but the [ForeignKey] attribute specified for both navigations have different values. + /// An invalid relationship has been specified using the [InverseProperty] and [ForeignKey] attributes. The navigations '{1_entityType}.{0_navigation}' and '{3_referencedEntityType}.{2_referencedNavigation}' are related by the [InverseProperty] attribute, but the [ForeignKey] attributes specified for both navigations have different values. Either specify the same properties or remove one of the attributes. /// public static string InvalidRelationshipUsingDataAnnotations([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object referencedNavigation, [CanBeNull] object referencedEntityType) => string.Format( @@ -1252,7 +1253,7 @@ public static string InvalidSetKeylessOperation([CanBeNull] object entityType) entityType); /// - /// Cannot create a DbSet for '{typeName}' because it is configured as an shared type entity type. Access the entity type via the `Set` method overload that accepts an entity type name. + /// Cannot create a DbSet for '{typeName}' because it is configured as an shared-type entity type. Access the entity type via the 'Set' method overload that accepts an entity type name. /// public static string InvalidSetSharedType([CanBeNull] object typeName) => string.Format( @@ -1268,15 +1269,15 @@ public static string InvalidSetType([CanBeNull] object typeName) typeName); /// - /// Cannot create a DbSet for '{typeName}' because it is configured as an owned entity type and must be accessed through its owning entity type. + /// Cannot create a DbSet for '{typeName}' because it is configured as an owned entity type and must be accessed through its owning entity type '{ownerType}'. /// - public static string InvalidSetTypeOwned([CanBeNull] object typeName) + public static string InvalidSetTypeOwned([CanBeNull] object typeName, [CanBeNull] object ownerType) => string.Format( - GetString("InvalidSetTypeOwned", nameof(typeName)), - typeName); + GetString("InvalidSetTypeOwned", nameof(typeName), nameof(ownerType)), + typeName, ownerType); /// - /// Cannot create a DbSet for '{typeName}' because it is mapped to multiple entity types and should be accessed through the owning entities. + /// 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. /// public static string InvalidSetTypeWeak([CanBeNull] object typeName) => string.Format( @@ -1324,7 +1325,7 @@ public static string InvalidValueGeneratorFactoryProperty([CanBeNull] object fac factory, property, entityType); /// - /// [InverseProperty] attributes on navigation '{1_entityType}.{0_navigation}' and on navigation '{3_referencedEntityType}.{2_referencedNavigation}' are not pointing to each other. + /// [InverseProperty] attributes on navigation '{1_entityType}.{0_navigation}' and on navigation '{3_referencedEntityType}.{2_referencedNavigation}' are not pointing to each other. Change the attributes to use the corresponding names or remove one of them. /// public static string InversePropertyMismatch([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object referencedNavigation, [CanBeNull] object referencedEntityType) => string.Format( @@ -1354,15 +1355,15 @@ public static string IQueryableProviderNotAsync => GetString("IQueryableProviderNotAsync"); /// - /// The derived type '{derivedType}' cannot have the [Key] attribute on property '{property}' since primary keys may only be declared on the root type. + /// The derived type '{derivedType}' cannot have the [Key] attribute on property '{property}' since primary keys may only be declared on the root type. Move the property '{property}' to '{rootType}' or remove '{rootType}' from the model by using [NotMapped] attribute or calling 'EntityTypeBuilder.Ignore' on the base type in 'OnModelCreating'. /// - public static string KeyAttributeOnDerivedEntity([CanBeNull] object derivedType, [CanBeNull] object property) + public static string KeyAttributeOnDerivedEntity([CanBeNull] object derivedType, [CanBeNull] object property, [CanBeNull] object rootType) => string.Format( - GetString("KeyAttributeOnDerivedEntity", nameof(derivedType), nameof(property)), - derivedType, property); + GetString("KeyAttributeOnDerivedEntity", nameof(derivedType), nameof(property), nameof(rootType)), + derivedType, property, rootType); /// - /// Cannot remove key {keyProperties} from entity type '{entityType}' because it is referenced by a foreign key {foreignKeyProperties} in entity type '{dependentType}'. All foreign keys must be removed or redefined before the referenced key can be removed. + /// Cannot remove key {keyProperties} from entity type '{entityType}' because it is referenced by a foreign key {foreignKeyProperties} defined on entity type '{dependentType}'. Remove or change the principal key for all referencing foreign keys before removing the key. /// public static string KeyInUse([CanBeNull] object keyProperties, [CanBeNull] object entityType, [CanBeNull] object foreignKeyProperties, [CanBeNull] object dependentType) => string.Format( @@ -1370,15 +1371,15 @@ public static string KeyInUse([CanBeNull] object keyProperties, [CanBeNull] obje keyProperties, entityType, foreignKeyProperties, dependentType); /// - /// The entity type '{entityType}' cannot be marked as keyless because it contains a key. + /// The entity type '{entityType}' cannot be marked as keyless because it contains a key {keyProperties}. /// - public static string KeylessTypeExistingKey([CanBeNull] object entityType) + public static string KeylessTypeExistingKey([CanBeNull] object entityType, [CanBeNull] object keyProperties) => string.Format( - GetString("KeylessTypeExistingKey", nameof(entityType)), - entityType); + GetString("KeylessTypeExistingKey", nameof(entityType), nameof(keyProperties)), + entityType, keyProperties); /// - /// Unable to track an instance of type '{type}' because it does not have a primary key. Only entity types with primary keys may be tracked. + /// Unable to track an instance of type '{type}' because it does not have a primary key. Only entity types with a primary key may be tracked. /// public static string KeylessTypeTracked([CanBeNull] object type) => string.Format( @@ -1450,7 +1451,7 @@ public static string MissingBackingField([CanBeNull] object field, [CanBeNull] o field, property, entityType); /// - /// Unable to set up a many-to-many relationship between the entity types '{principalEntityType}' and '{declaringEntityType}' because one of the navigations was not specified. Please provide a navigation in the 'HasMany' call in 'OnModelCreating'. + /// Unable to set up a many-to-many relationship between the entity types '{principalEntityType}' and '{declaringEntityType}' because one of the navigations was not specified. Provide a navigation in the 'HasMany' call in 'OnModelCreating'. /// public static string MissingInverseManyToManyNavigation([CanBeNull] object principalEntityType, [CanBeNull] object declaringEntityType) => string.Format( @@ -1482,20 +1483,20 @@ public static string MultipleFilteredIncludesOnSameNavigation([CanBeNull] object filter1, filter2); /// - /// There are multiple navigations in entity type '{entityType}' which are pointing to same set of properties using a [ForeignKey] attribute: '{propertyList}' + /// There are multiple navigations in entity type '{entityType}' which are pointing to same set of properties '{properties}' using a [ForeignKey] attribute: {navigations}. /// - public static string MultipleNavigationsSameFk([CanBeNull] object entityType, [CanBeNull] object propertyList) + public static string MultipleNavigationsSameFk([CanBeNull] object entityType, [CanBeNull] object properties, [CanBeNull] object navigations) => string.Format( - GetString("MultipleNavigationsSameFk", nameof(entityType), nameof(propertyList)), - entityType, propertyList); + GetString("MultipleNavigationsSameFk", nameof(entityType), nameof(properties), nameof(navigations)), + entityType, properties, navigations); /// - /// The entity type '{entityType}' is the target of multiple ownership relationships. + /// The entity type '{entityType}' is the target of multiple ownership relationships: {navigations}. /// - public static string MultipleOwnerships([CanBeNull] object entityType) + public static string MultipleOwnerships([CanBeNull] object entityType, [CanBeNull] object navigations) => string.Format( - GetString("MultipleOwnerships", nameof(entityType)), - entityType); + GetString("MultipleOwnerships", nameof(entityType), nameof(navigations)), + entityType, navigations); /// /// Services for database providers {storeNames} have been registered in the service provider. Only a single database provider can be registered in a service provider. If possible, ensure that Entity Framework is managing its service provider by removing the call to 'UseInternalServiceProvider'. Otherwise, consider conditionally registering the database provider, or maintaining one service provider per database provider. @@ -1506,7 +1507,7 @@ public static string MultipleProvidersConfigured([CanBeNull] object storeNames) storeNames); /// - /// The property '{keyProperty}' cannot be configured as 'ValueGeneratedOnUpdate' or 'ValueGeneratedOnAddOrUpdate' because the key value cannot be changed after the entity has been added to the store. + /// The property '{keyProperty}' cannot be configured as 'ValueGeneratedOnUpdate' or 'ValueGeneratedOnAddOrUpdate' because it's part of a key and its value cannot be changed after the entity has been added to the store. /// public static string MutableKeyProperty([CanBeNull] object keyProperty) => string.Format( @@ -1514,20 +1515,20 @@ public static string MutableKeyProperty([CanBeNull] object keyProperty) keyProperty); /// - /// The index named '{indexName}' on the entity type '{entityType}' with properties {indexPropertyList} is invalid. The property '{propertyName}' has been marked as unmapped via the [NotMapped] attribute or the 'EntityTypeBuilder.Ignore' fluent API. An index cannot use unmapped properties. + /// The index '{indexName}' specified via [Index] attribute on the entity type '{entityType}' with properties {indexProperties} is invalid. The property '{propertyName}' has been marked as unmapped via the [NotMapped] attribute or the 'EntityTypeBuilder.Ignore' fluent API. An index cannot use unmapped properties. /// - public static string NamedIndexDefinedOnIgnoredProperty([CanBeNull] object indexName, [CanBeNull] object entityType, [CanBeNull] object indexPropertyList, [CanBeNull] object propertyName) + public static string NamedIndexDefinedOnIgnoredProperty([CanBeNull] object indexName, [CanBeNull] object entityType, [CanBeNull] object indexProperties, [CanBeNull] object propertyName) => string.Format( - GetString("NamedIndexDefinedOnIgnoredProperty", nameof(indexName), nameof(entityType), nameof(indexPropertyList), nameof(propertyName)), - indexName, entityType, indexPropertyList, propertyName); + GetString("NamedIndexDefinedOnIgnoredProperty", nameof(indexName), nameof(entityType), nameof(indexProperties), nameof(propertyName)), + indexName, entityType, indexProperties, propertyName); /// - /// An index named '{indexName}' on entity type '{entityType}' specifies properties {indexPropertyList}, but no property with name '{propertyName}' exists on that entity type or any of its base types. + /// An index '{indexName}' 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. /// - public static string NamedIndexDefinedOnNonExistentProperty([CanBeNull] object indexName, [CanBeNull] object entityType, [CanBeNull] object indexPropertyList, [CanBeNull] object propertyName) + public static string NamedIndexDefinedOnNonExistentProperty([CanBeNull] object indexName, [CanBeNull] object entityType, [CanBeNull] object indexProperties, [CanBeNull] object propertyName) => string.Format( - GetString("NamedIndexDefinedOnNonExistentProperty", nameof(indexName), nameof(entityType), nameof(indexPropertyList), nameof(propertyName)), - indexName, entityType, indexPropertyList, propertyName); + GetString("NamedIndexDefinedOnNonExistentProperty", nameof(indexName), nameof(entityType), nameof(indexProperties), nameof(propertyName)), + indexName, entityType, indexProperties, propertyName); /// /// The index with name {indexName} cannot be removed from the entity type '{entityType}' because no such index exists on that entity type. @@ -1538,7 +1539,7 @@ public static string NamedIndexWrongType([CanBeNull] object indexName, [CanBeNul indexName, entityType); /// - /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which is an array type. Collection navigation properties cannot be arrays. + /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which is an array type. Collection navigations cannot be arrays. /// public static string NavigationArray([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object foundType) => string.Format( @@ -1546,7 +1547,7 @@ public static string NavigationArray([CanBeNull] object navigation, [CanBeNull] navigation, entityType, foundType); /// - /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which does not implement ICollection<{targetType}>. Collection navigation properties must implement ICollection<> of the target type. + /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which does not implement 'ICollection<{targetType}>'. Collection navigations must implement 'ICollection<>' of the target type. /// public static string NavigationBadType([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object foundType, [CanBeNull] object targetType) => string.Format( @@ -1554,7 +1555,7 @@ public static string NavigationBadType([CanBeNull] object navigation, [CanBeNull navigation, entityType, foundType, targetType); /// - /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' for which it was not possible to create a concrete instance. Either initialize the property before use, add a public parameterless constructor to the type, or use a type which can be assigned a HashSet<> or List<>. + /// The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' for which it was not possible to create a concrete instance. Either initialize the property before use, add a public parameterless constructor to the type, or use a type which can be assigned a 'HashSet<>' or 'List<>'. /// public static string NavigationCannotCreateType([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object foundType) => string.Format( @@ -1562,7 +1563,7 @@ public static string NavigationCannotCreateType([CanBeNull] object navigation, [ navigation, entityType, foundType); /// - /// The collection navigation '{navigation}' cannot be added to the entity type '{entityType}' because its CLR type '{clrType}' does not implement 'IEnumerable<{targetType}>'. Collection navigation properties must implement IEnumerable<> of the related entity. + /// The collection navigation '{navigation}' cannot be added to the entity type '{entityType}' because its CLR type '{clrType}' does not implement 'IEnumerable<{targetType}>'. Collection navigations must implement IEnumerable<> of the related entity. /// public static string NavigationCollectionWrongClrType([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object clrType, [CanBeNull] object targetType) => string.Format( @@ -1570,12 +1571,12 @@ public static string NavigationCollectionWrongClrType([CanBeNull] object navigat navigation, entityType, clrType, targetType); /// - /// The navigation '{1_entityType}.{0_navigation}' cannot be associated with foreign key {targetFk} because it was created for foreign key {actualFk}. + /// The navigation '{1_entityType}.{0_navigation}' cannot be associated with foreign key {targetForeignKeyProperties} because it was created for foreign key {actualForeignKeyProperties}. /// - public static string NavigationForWrongForeignKey([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object targetFk, [CanBeNull] object actualFk) + public static string NavigationForWrongForeignKey([CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object targetForeignKeyProperties, [CanBeNull] object actualForeignKeyProperties) => string.Format( - GetString("NavigationForWrongForeignKey", "0_navigation", "1_entityType", nameof(targetFk), nameof(actualFk)), - navigation, entityType, targetFk, actualFk); + GetString("NavigationForWrongForeignKey", "0_navigation", "1_entityType", nameof(targetForeignKeyProperties), nameof(actualForeignKeyProperties)), + navigation, entityType, targetForeignKeyProperties, actualForeignKeyProperties); /// /// The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' or '{collectionMethod}' method, but is defined in the model as a non-navigation. Use the '{propertyMethod}' method to access non-navigation properties. @@ -1586,7 +1587,7 @@ public static string NavigationIsProperty([CanBeNull] object property, [CanBeNul property, entityType, referenceMethod, collectionMethod, propertyMethod); /// - /// The navigation '{1_entityType}.{0_navigation}' does not have a setter and no writable backing field was found or specified. Read-only collection navigation properties must be initialized before use. + /// The navigation '{1_entityType}.{0_navigation}' does not have a setter and no writable backing field was found or specified. Read-only collection navigations must be initialized before use. /// public static string NavigationNoSetter([CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -1634,7 +1635,7 @@ public static string NoBackingField([CanBeNull] object property, [CanBeNull] obj property, entityType, propertyAccessMode); /// - /// No backing field was found for property '{1_entityType}.{0_property}'. Lazy-loaded navigation properties must have backing fields. Either name the backing field so that it is discovered by convention or configure the backing field to use. + /// No backing field was found for property '{1_entityType}.{0_property}'. Lazy-loaded navigations must have backing fields. Either name the backing field so that it is discovered by convention or configure the backing field to use. /// public static string NoBackingFieldLazyLoading([CanBeNull] object property, [CanBeNull] object entityType) => string.Format( @@ -1666,7 +1667,7 @@ public static string NoDefiningNavigation([CanBeNull] object navigation, [CanBeN navigation, entityType, definingEntityType); /// - /// Cannot set the discriminator value for entity type '{entityType}' because the root entity type '{rootEntityType}' doesn't have a discriminator property set. + /// Cannot set the discriminator value for entity type '{entityType}' because the root entity type '{rootEntityType}' doesn't have a discriminator property configured. /// public static string NoDiscriminatorForValue([CanBeNull] object entityType, [CanBeNull] object rootEntityType) => string.Format( @@ -1728,6 +1729,7 @@ public static string NoInterceptionResult /// /// There is no navigation on entity type '{entityType}' associated with the foreign key {foreignKeyProperties}. /// + [Obsolete] public static string NoNavigation([CanBeNull] object entityType, [CanBeNull] object foreignKeyProperties) => string.Format( GetString("NoNavigation", nameof(entityType), nameof(foreignKeyProperties)), @@ -1758,7 +1760,7 @@ public static string NonComparableKeyTypes([CanBeNull] object entityType, [CanBe entityType, property, modelType, providerType); /// - /// The navigation '{1_entityType}.{0_navigation}' must be configured in 'OnModelCreating' with an explicit name for the target shared type entity type, or excluded by calling 'EntityTypeBuilder.Ignore'. + /// The navigation '{1_entityType}.{0_navigation}' must be configured in 'OnModelCreating' with an explicit name for the target shared-type entity type, or excluded by calling 'EntityTypeBuilder.Ignore'. /// public static string NonConfiguredNavigationToSharedType([CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -1766,11 +1768,11 @@ public static string NonConfiguredNavigationToSharedType([CanBeNull] object navi navigation, entityType); /// - /// The ownership by '{ownershipNavigation}' should use defining navigation '{definingNavigation}' for the owned type '{entityType}' + /// The entity type '{2_entityType}' owned by '{0_ownershipNavigation}' should use defining navigation '{1_definingNavigation}' for . /// public static string NonDefiningOwnership([CanBeNull] object ownershipNavigation, [CanBeNull] object definingNavigation, [CanBeNull] object entityType) => string.Format( - GetString("NonDefiningOwnership", nameof(ownershipNavigation), nameof(definingNavigation), nameof(entityType)), + GetString("NonDefiningOwnership", "0_ownershipNavigation", "1_definingNavigation", "2_entityType"), ownershipNavigation, definingNavigation, entityType); /// @@ -1782,11 +1784,11 @@ public static string NonGenericOptions([CanBeNull] object contextType) contextType); /// - /// Cannot add property '{1_entityType}.{0_property}' since there is no indexer on '{1_entityType}' taking a single argument of type '{type}'. + /// Cannot add indexer property '{property}' since there is no indexer on '{entityType}' taking a single argument of type assignable from '{type}'. /// public static string NonIndexerEntityType([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object type) => string.Format( - GetString("NonIndexerEntityType", "0_property", "1_entityType", nameof(type)), + GetString("NonIndexerEntityType", nameof(property), nameof(entityType), nameof(type)), property, entityType, type); /// @@ -1814,7 +1816,7 @@ public static string NonUniqueRequiredDependentForeignKey([CanBeNull] object for foreignKeyProperties, declaringEntityType); /// - /// '{principalEntityType}.{principalNavigation}' cannot be configured as required since it contains a collection. + /// '{principalEntityType}.{principalNavigation}' cannot be configured as required since it was configured as a collection. /// public static string NonUniqueRequiredDependentNavigation([CanBeNull] object principalEntityType, [CanBeNull] object principalNavigation) => string.Format( @@ -1936,7 +1938,7 @@ public static string OwnedEntitiesCannotBeTrackedWithoutTheirOwner => GetString("OwnedEntitiesCannotBeTrackedWithoutTheirOwner"); /// - /// The owned entity type '{ownedType}' must be referenced from another entity type via a navigation. Add a navigation to an entity type that points at '{ownedType}'. + /// The entity type '{ownedType}' has been marked as owned and must be referenced from another entity type via a navigation. Add a navigation to an entity type that points at '{ownedType}' or don't configure it as owned. /// public static string OwnerlessOwnedType([CanBeNull] object ownedType) => string.Format( @@ -1958,7 +1960,7 @@ public static string PoolingOptionsModified => GetString("PoolingOptionsModified"); /// - /// You are configuring a relationship between '{dependentEntityType}' and '{principalEntityType}', but have specified a foreign key targeting '{entityType}'. The foreign key must target a type that is part of the relationship. + /// You are configuring a relationship between '{dependentEntityType}' and '{principalEntityType}', but have specified a principal key on '{entityType}'. The foreign key must target a type that is part of the relationship. /// public static string PrincipalEntityTypeNotInRelationship([CanBeNull] object dependentEntityType, [CanBeNull] object principalEntityType, [CanBeNull] object entityType) => string.Format( @@ -1966,7 +1968,7 @@ public static string PrincipalEntityTypeNotInRelationship([CanBeNull] object dep dependentEntityType, principalEntityType, entityType); /// - /// The entity type '{entityType}' cannot be on the principal end of the relationship between '{firstNavigationSpecification}' and '{secondNavigationSpecification}'. The principal entity type must have a key. + /// The keyless entity type '{entityType}' cannot be on the principal end of the relationship between '{firstNavigationSpecification}' and '{secondNavigationSpecification}'. The principal entity type must have a key. /// public static string PrincipalKeylessType([CanBeNull] object entityType, [CanBeNull] object firstNavigationSpecification, [CanBeNull] object secondNavigationSpecification) => string.Format( @@ -1974,7 +1976,7 @@ public static string PrincipalKeylessType([CanBeNull] object entityType, [CanBeN entityType, firstNavigationSpecification, secondNavigationSpecification); /// - /// The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' is not supported because the owned entity type '{ownedType}' cannot be on the principal side of a non-ownership relationship. + /// The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' is not supported because the owned entity type '{ownedType}' cannot be on the principal side of a non-ownership relationship. Remove the relationship or configure the foreign key to be on '{ownedType}'. /// public static string PrincipalOwnedType([CanBeNull] object referencingEntityTypeOrNavigation, [CanBeNull] object referencedEntityTypeOrNavigation, [CanBeNull] object ownedType) => string.Format( @@ -1990,7 +1992,7 @@ public static string PropertyCalledOnNavigation([CanBeNull] object property, [Ca property, entityType); /// - /// The indexer property '{property}' cannot be added to type '{entityType}' because the CLR type contains a member with the same name. + /// The indexer property '{property}' cannot be added to type '{entityType}' because the CLR type contains a member with the same name. Specify a different name or configure '{property}' as a non-indexer property. /// public static string PropertyClashingNonIndexer([CanBeNull] object property, [CanBeNull] object entityType) => string.Format( @@ -2046,7 +2048,7 @@ public static string PropertyInUseKey([CanBeNull] object property, [CanBeNull] o property, entityType, keyProperties); /// - /// The property '{1_entityType}.{0_property}' is being accessed using the '{propertyMethod}' method, but is defined in the model as a navigation. Use either the '{referenceMethod}' or '{collectionMethod}' method to access navigation properties. + /// The property '{1_entityType}.{0_property}' is being accessed using the '{propertyMethod}' method, but is defined in the model as a navigation. Use either the '{referenceMethod}' or '{collectionMethod}' method to access navigations. /// public static string PropertyIsNavigation([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object propertyMethod, [CanBeNull] object referenceMethod, [CanBeNull] object collectionMethod) => string.Format( @@ -2108,7 +2110,7 @@ public static string PropertyWrongClrType([CanBeNull] object property, [CanBeNul property, entityType, clrType, propertyType); /// - /// The CLR property '{property}' cannot be added to entity type '{entityType}' because it is declared on the CLR type '{clrType}'. + /// The property '{property}' cannot be added to entity type '{entityType}' because it is declared on the CLR type '{clrType}'. /// public static string PropertyWrongEntityClrType([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object clrType) => string.Format( @@ -2116,7 +2118,7 @@ public static string PropertyWrongEntityClrType([CanBeNull] object property, [Ca property, entityType, clrType); /// - /// The property '{property}' cannot be added to type '{entityType}' because the name of the given CLR property or field '{clrName}' is different. + /// The property '{property}' cannot be added to entity type '{entityType}' because it doesn't match the name of the provided CLR property or field '{clrName}'. Use the same name or specify a different CLR member. /// public static string PropertyWrongName([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object clrName) => string.Format( @@ -2138,7 +2140,7 @@ public static string QueryContextAlreadyInitializedStateManager => GetString("QueryContextAlreadyInitializedStateManager"); /// - /// The materialization condition passed for entity shaper of entity type '{entityType}' is not of the correct shape. A materialization condition must be a 'LambdaExpression' of 'Func<ValueBuffer, IEntityType>' + /// The materialization condition passed for entity shaper of entity type '{entityType}' is not of the correct shape. A materialization condition must be a 'LambdaExpression' of 'Func<ValueBuffer, IEntityType>'. /// public static string QueryEntityMaterializationConditionWrongShape([CanBeNull] object entityType) => string.Format( @@ -2204,7 +2206,7 @@ public static string RecursiveOnModelCreating => GetString("RecursiveOnModelCreating"); /// - /// The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' with foreign key properties {foreignKeyPropertiesWithTypes} cannot target the primary key {primaryKeyPropertiesWithTypes} because it is not compatible. Configure a principal key or a set of compatible foreign key properties for this relationship. + /// The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' with foreign key properties {foreignKeyPropertiesWithTypes} cannot target the primary key {primaryKeyPropertiesWithTypes} because it is not compatible. Configure a principal key or a set of foreign key properties with compatible types for this relationship. /// public static string ReferencedShadowKey([CanBeNull] object referencingEntityTypeOrNavigation, [CanBeNull] object referencedEntityTypeOrNavigation, [CanBeNull] object foreignKeyPropertiesWithTypes, [CanBeNull] object primaryKeyPropertiesWithTypes) => string.Format( @@ -2212,7 +2214,7 @@ public static string ReferencedShadowKey([CanBeNull] object referencingEntityTyp referencingEntityTypeOrNavigation, referencedEntityTypeOrNavigation, foreignKeyPropertiesWithTypes, primaryKeyPropertiesWithTypes); /// - /// The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' method, but is defined in the model as a collection navigation. Use the '{collectionMethod}' method to access collection navigation properties. + /// The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' method, but is defined in the model as a collection navigation. Use the '{collectionMethod}' method to access collection navigations. /// public static string ReferenceIsCollection([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object referenceMethod, [CanBeNull] object collectionMethod) => string.Format( @@ -2228,7 +2230,7 @@ public static string ReferenceMustBeLoaded([CanBeNull] object navigation, [CanBe navigation, entityType); /// - /// The principal and dependent ends of the relationship cannot be inverted once foreign key or principal key properties have been specified. + /// The principal and dependent ends of the relationship cannot be changed once foreign key or principal key properties have been specified. Remove the conflicting configuration. /// public static string RelationshipCannotBeInverted => GetString("RelationshipCannotBeInverted"); @@ -2310,7 +2312,7 @@ public static string SeedDatumDuplicateSensitive([CanBeNull] object entityType, entityType, keyValue); /// - /// The seed entity for entity type '{entityType}' cannot be added because the value provided for the property '{property}' is not of type '{type}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the involved property values. + /// The seed entity for entity type '{entityType}' cannot be added because the value provided for the property '{property}' is not compatible with the property type '{type}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the involved property value. /// public static string SeedDatumIncompatibleValue([CanBeNull] object entityType, [CanBeNull] object property, [CanBeNull] object type) => string.Format( @@ -2318,7 +2320,7 @@ public static string SeedDatumIncompatibleValue([CanBeNull] object entityType, [ entityType, property, type); /// - /// The seed entity for entity type '{entityType}' cannot be added because the value '{value}' provided for the property '{property}' is not of type '{type}'. + /// The seed entity for entity type '{entityType}' cannot be added because the value '{value}' provided for the property '{property}' is not compatible with the property type '{type}'. /// public static string SeedDatumIncompatibleValueSensitive([CanBeNull] object entityType, [CanBeNull] object value, [CanBeNull] object property, [CanBeNull] object type) => string.Format( @@ -2358,12 +2360,12 @@ public static string SeedDatumSignedNumericValue([CanBeNull] object entityType, entityType, property); /// - /// A relationship cannot be established from property '{1_entityType}.{0_property}' to property '{3_referencedEntityType}.{2_referencedProperty}'. Check the values in the [InverseProperty] attribute to ensure relationship definitions are unique and reference from one navigation to its corresponding inverse navigation. + /// The inverse for the navigation '{entityType}.{property}' cannot be the same navigation. Change the value in the [InverseProperty] attribute to a different navigation. /// - public static string SelfReferencingNavigationWithInverseProperty([CanBeNull] object property, [CanBeNull] object entityType, [CanBeNull] object referencedProperty, [CanBeNull] object referencedEntityType) + public static string SelfReferencingNavigationWithInverseProperty([CanBeNull] object entityType, [CanBeNull] object property) => string.Format( - GetString("SelfReferencingNavigationWithInverseProperty", "0_property", "1_entityType", "2_referencedProperty", "3_referencedEntityType"), - property, entityType, referencedProperty, referencedEntityType); + GetString("SelfReferencingNavigationWithInverseProperty", nameof(entityType), nameof(property)), + entityType, property); /// /// To show additional information call 'DbContextOptionsBuilder.EnableSensitiveDataLogging'. @@ -2414,7 +2416,7 @@ public static string SetOperationWithDifferentIncludesInOperands => GetString("SetOperationWithDifferentIncludesInOperands"); /// - /// The entity type '{entityType}' is in shadow state. A valid model requires all entity types to have corresponding CLR type. + /// The entity type '{entityType}' is in shadow state. A valid model requires all entity types to have a corresponding CLR type. /// public static string ShadowEntity([CanBeNull] object entityType) => string.Format( @@ -2422,7 +2424,7 @@ public static string ShadowEntity([CanBeNull] object entityType) entityType); /// - /// The shared type entity type '{entityType}' cannot have a base type. + /// The shared-type entity type '{entityType}' cannot have a base type. /// public static string SharedTypeDerivedType([CanBeNull] object entityType) => string.Format( @@ -2446,7 +2448,7 @@ public static string SingletonRequired([CanBeNull] object scope, [CanBeNull] obj scope, service); /// - /// The foreign key {foreignKeyProperties} cannot be set for the skip navigation '{navigation}' as it uses the join entity type '{joinType}' while the inverse skip navigation '{inverse}' is using the join entity type '{inverseJoinType}'. The inverse navigation must use the same join entity type. + /// The foreign key {foreignKeyProperties} cannot be set for the skip navigation '{navigation}' as it uses the join entity type '{joinType}' while the inverse skip navigation '{inverse}' is associated with a foreign key using the join entity type '{inverseJoinType}'. The inverse navigation must use the same join entity type. /// public static string SkipInverseMismatchedForeignKey([CanBeNull] object foreignKeyProperties, [CanBeNull] object navigation, [CanBeNull] object joinType, [CanBeNull] object inverse, [CanBeNull] object inverseJoinType) => string.Format( @@ -2462,28 +2464,28 @@ public static string SkipInverseMismatchedJoinType([CanBeNull] object inverse, [ inverse, inverseJoinType, navigation, joinType); /// - /// The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{2_entityType}.{1_navigation}' because it is expected to be on the dependent entity type '{dependentEntityType}'. + /// The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{entityType}.{navigation}' because it is declared on the entity type '{dependentEntityType}', but a foreign key on '{entityType}' is expected. /// - public static string SkipNavigationForeignKeyWrongDependentType([CanBeNull] object foreignKeyProperties, [CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object dependentEntityType) + public static string SkipNavigationForeignKeyWrongDependentType([CanBeNull] object foreignKeyProperties, [CanBeNull] object entityType, [CanBeNull] object navigation, [CanBeNull] object dependentEntityType) => string.Format( - GetString("SkipNavigationForeignKeyWrongDependentType", nameof(foreignKeyProperties), "1_navigation", "2_entityType", nameof(dependentEntityType)), - foreignKeyProperties, navigation, entityType, dependentEntityType); + GetString("SkipNavigationForeignKeyWrongDependentType", nameof(foreignKeyProperties), nameof(entityType), nameof(navigation), nameof(dependentEntityType)), + foreignKeyProperties, entityType, navigation, dependentEntityType); /// - /// The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{2_entityType}.{1_navigation}' because it is expected to be on the principal entity type '{principalEntityType}'. + /// The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{entityType}.{navigation}' because it is declared on the entity type '{entityType}', but a foreign key on '{principalEntityType}' is expected. /// - public static string SkipNavigationForeignKeyWrongPrincipalType([CanBeNull] object foreignKeyProperties, [CanBeNull] object navigation, [CanBeNull] object entityType, [CanBeNull] object principalEntityType) + public static string SkipNavigationForeignKeyWrongPrincipalType([CanBeNull] object foreignKeyProperties, [CanBeNull] object entityType, [CanBeNull] object navigation, [CanBeNull] object principalEntityType) => string.Format( - GetString("SkipNavigationForeignKeyWrongPrincipalType", nameof(foreignKeyProperties), "1_navigation", "2_entityType", nameof(principalEntityType)), - foreignKeyProperties, navigation, entityType, principalEntityType); + GetString("SkipNavigationForeignKeyWrongPrincipalType", nameof(foreignKeyProperties), nameof(entityType), nameof(navigation), nameof(principalEntityType)), + foreignKeyProperties, entityType, navigation, principalEntityType); /// - /// The skip navigation '{skipNavigation}' cannot be removed because it is set as the inverse of the skip navigation '{inverseSkipNavigation}' on '{referencingEntityType}'. All referencing skip navigations must be removed before this skip navigation can be removed. + /// The skip navigation '{entityType}.{skipNavigation}' cannot be removed because it is configured as the inverse of the skip navigation '{referencingEntityType}.{inverseSkipNavigation}'. All referencing skip navigations must be removed before this skip navigation can be removed. /// - public static string SkipNavigationInUseBySkipNavigation([CanBeNull] object skipNavigation, [CanBeNull] object inverseSkipNavigation, [CanBeNull] object referencingEntityType) + public static string SkipNavigationInUseBySkipNavigation([CanBeNull] object entityType, [CanBeNull] object skipNavigation, [CanBeNull] object referencingEntityType, [CanBeNull] object inverseSkipNavigation) => string.Format( - GetString("SkipNavigationInUseBySkipNavigation", nameof(skipNavigation), nameof(inverseSkipNavigation), nameof(referencingEntityType)), - skipNavigation, inverseSkipNavigation, referencingEntityType); + GetString("SkipNavigationInUseBySkipNavigation", nameof(entityType), nameof(skipNavigation), nameof(referencingEntityType), nameof(inverseSkipNavigation)), + entityType, skipNavigation, referencingEntityType, inverseSkipNavigation); /// /// The skip navigation '{1_entityType}.{0_navigation}' doesn't have a foreign key associated with it. Every skip navigation must have a configured foreign key. @@ -2494,7 +2496,7 @@ public static string SkipNavigationNoForeignKey([CanBeNull] object navigation, [ navigation, entityType); /// - /// The skip navigation '{1_entityType}.{0_navigation}' doesn't have an inverse navigation configured. Every skip navigation should must an inverse skip navigation. + /// The skip navigation '{1_entityType}.{0_navigation}' doesn't have an inverse navigation configured. Every skip navigation should have an inverse skip navigation. /// public static string SkipNavigationNoInverse([CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -2502,7 +2504,7 @@ public static string SkipNavigationNoInverse([CanBeNull] object navigation, [Can navigation, entityType); /// - /// The skip navigation '{1_entityType}.{0_navigation}' is not a collection. Only collection skip navigation properties are currently supported. + /// The skip navigation '{1_entityType}.{0_navigation}' is not a collection. Only collection skip navigations are currently supported. /// public static string SkipNavigationNonCollection([CanBeNull] object navigation, [CanBeNull] object entityType) => string.Format( @@ -2580,7 +2582,7 @@ public static string TranslationFailedWithDetails([CanBeNull] object expression, expression, details); /// - /// The type '{type}' is not been configured as a shared type in the model. Before calling 'UsingEntity', please mark the type as shared or add the entity type in the model as a shared entity. + /// The type '{type}' has not been configured as a shared type in the model. Before calling 'UsingEntity' add the entity type in the model as a shared entity. /// public static string TypeNotMarkedAsShared([CanBeNull] object type) => string.Format( @@ -2596,7 +2598,7 @@ public static string UnableToDiscriminate([CanBeNull] object entityType, [CanBeN entityType, discriminator); /// - /// Unable to set IsUnique to '{isUnique}' on the relationship underlying the navigation '{2_entityType}.{1_navigationName}' because the navigation has the opposite multiplicity. + /// Unable to set 'IsUnique' to '{isUnique}' on the relationship associated with the navigation '{2_entityType}.{1_navigationName}' because the navigation has the opposite multiplicity. /// public static string UnableToSetIsUnique([CanBeNull] object isUnique, [CanBeNull] object navigationName, [CanBeNull] object entityType) => string.Format( @@ -2644,20 +2646,20 @@ public static string UnknownKeyValue([CanBeNull] object entityType, [CanBeNull] entityType, property); /// - /// The unnamed index on the entity type '{entityType}' with properties {indexPropertyList} is invalid. The property '{propertyName}' was marked as unmapped by [NotMapped] attribute or 'Ignore()' in 'OnModelCreating'. An index cannot use unmapped properties. + /// The unnamed index specified via [Index] attribute on the entity type '{entityType}' with properties {indexProperties} is invalid. The property '{propertyName}' was marked as unmapped by [NotMapped] attribute or 'Ignore()' in 'OnModelCreating'. An index cannot use unmapped properties. /// - public static string UnnamedIndexDefinedOnIgnoredProperty([CanBeNull] object entityType, [CanBeNull] object indexPropertyList, [CanBeNull] object propertyName) + public static string UnnamedIndexDefinedOnIgnoredProperty([CanBeNull] object entityType, [CanBeNull] object indexProperties, [CanBeNull] object propertyName) => string.Format( - GetString("UnnamedIndexDefinedOnIgnoredProperty", nameof(entityType), nameof(indexPropertyList), nameof(propertyName)), - entityType, indexPropertyList, propertyName); + GetString("UnnamedIndexDefinedOnIgnoredProperty", nameof(entityType), nameof(indexProperties), nameof(propertyName)), + entityType, indexProperties, propertyName); /// - /// An unnamed index on the entity type '{entityType}' specifies properties {indexPropertyList}, but no property with name '{propertyName}' exists on that entity type or any of its base types. + /// 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. /// - public static string UnnamedIndexDefinedOnNonExistentProperty([CanBeNull] object entityType, [CanBeNull] object indexPropertyList, [CanBeNull] object propertyName) + public static string UnnamedIndexDefinedOnNonExistentProperty([CanBeNull] object entityType, [CanBeNull] object indexProperties, [CanBeNull] object propertyName) => string.Format( - GetString("UnnamedIndexDefinedOnNonExistentProperty", nameof(entityType), nameof(indexPropertyList), nameof(propertyName)), - entityType, indexPropertyList, propertyName); + GetString("UnnamedIndexDefinedOnNonExistentProperty", nameof(entityType), nameof(indexProperties), nameof(propertyName)), + entityType, indexProperties, propertyName); /// /// 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. @@ -2998,7 +3000,7 @@ public static EventDefinition LogConflictingKeylessAndKeyAttribu } /// - /// There are multiple relationships between '{dependentEntityType}' and '{principalEntityType}' without configured foreign key properties. This will cause Entity Framework to create shadow properties on '{dependentType}' with names dependent on the discovery order. + /// There are multiple relationships between '{dependentEntityType}' and '{principalEntityType}' without configured foreign key properties. This will cause Entity Framework to create shadow properties on '{dependentType}' with names dependent on the discovery order. Consider configuring the foreign key properties using the [ForeignKey] attribute or in 'OnModelCreating'. /// public static EventDefinition LogConflictingShadowForeignKeys([NotNull] IDiagnosticsLogger logger) { @@ -3262,7 +3264,7 @@ public static EventDefinition LogFirstWithoutOrderByAndFilter([NotNull] IDiagnos } /// - /// Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships as the [ForeignKey] attribute was specified on navigations on both sides. + /// Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships since the [ForeignKey] attribute was specified on navigations on both sides. /// public static EventDefinition LogForeignKeyAttributesOnBothNavigations([NotNull] IDiagnosticsLogger logger) { @@ -3286,7 +3288,7 @@ public static EventDefinition LogForeignKeyAttri } /// - /// Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships as the [ForeignKey] attribute was specified on properties '{dependentProperty}' and '{principalProperty}' on both sides. + /// Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships since the [ForeignKey] attribute was specified on properties '{dependentProperty}' and '{principalProperty}' on both sides. /// public static EventDefinition LogForeignKeyAttributesOnBothProperties([NotNull] IDiagnosticsLogger logger) { @@ -3454,7 +3456,7 @@ public static EventDefinition LogManyServiceProvidersCreated([NotNull] IDiagnost } /// - /// There are multiple navigations ({navigations}) configured with [InverseProperty] attribute which point to the same inverse navigation '{inverseNavigation}'. + /// There are multiple navigations ({navigations}) configured with [InverseProperty] attribute which point to the same inverse navigation '{inverseNavigation}' therefore no relationship was configured by convention. /// public static EventDefinition LogMultipleInversePropertiesSameTarget([NotNull] IDiagnosticsLogger logger) { @@ -3478,7 +3480,7 @@ public static EventDefinition LogMultipleInversePropertiesSameTa } /// - /// No relationship from '{firstEntityType}' to '{secondEntityType}' has been configured by convention because there are multiple properties on one entity type {navigationProperties} that could be matched with the properties on the other entity type {inverseNavigations}. This message can be disregarded if explicit configuration has been specified in 'OnModelCreating'. + /// No relationship from '{firstEntityType}' to '{secondEntityType}' has been configured by convention because there are multiple properties on one entity type - {navigationProperties} that could be matched with the properties on the other entity type - {inverseNavigations}. This message can be disregarded if explicit configuration has been specified in 'OnModelCreating'. /// public static EventDefinition LogMultipleNavigationProperties([NotNull] IDiagnosticsLogger logger) { @@ -3574,7 +3576,7 @@ public static EventDefinition LogNavigationLazyLoading([NotNull] } /// - /// The navigation '{targetEntityType}.{inverseNavigation}' cannot be used as the inverse of '{weakEntityType}.{navigation}' because it's not the defining navigation '{definingNavigation}' + /// 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}'. /// public static EventDefinition LogNonDefiningInverseNavigation([NotNull] IDiagnosticsLogger logger) { @@ -3673,7 +3675,7 @@ public static EventDefinition LogNonNullableReferenceOnDependent } /// - /// The navigation '{targetEntityType}.{inverseNavigation}' cannot be used as the inverse of '{ownedEntityType}.{navigation}' because it's not the ownership navigation '{ownershipNavigation}' + /// The navigation '{targetEntityType}.{inverseNavigation}' specified in the [InverseProperty] attribute cannot be used as the inverse of '{ownedEntityType}.{navigation}' because it's not the ownership navigation '{ownershipNavigation}'. /// public static EventDefinition LogNonOwnershipInverseNavigation([NotNull] IDiagnosticsLogger logger) { @@ -3913,7 +3915,7 @@ public static EventDefinition LogRedundantAddServicesCall([NotNull] IDiagnostics } /// - /// The foreign key {redundantForeignKey} on entity type '{entityType} targets itself. Consider removing it since it serves no purpose. + /// The foreign key {redundantForeignKeyProperties} on entity type '{entityType}' targets itself. Consider removing it since it serves no purpose. /// public static EventDefinition LogRedundantForeignKey([NotNull] IDiagnosticsLogger logger) { @@ -3937,7 +3939,7 @@ public static EventDefinition LogRedundantForeignKey([NotNull] I } /// - /// The index {redundantIndex} was not created on entity type '{firstEntityType}' as the properties are already covered by the index {otherIndex}. + /// The index {redundantIndexProperties} was not created on entity type '{firstEntityType}' as the properties are already covered by the index {otherIndexProperties}. /// public static EventDefinition LogRedundantIndexRemoved([NotNull] IDiagnosticsLogger logger) { diff --git a/src/EFCore/Properties/CoreStrings.resx b/src/EFCore/Properties/CoreStrings.resx index cdad1deef94..7e5a6fda0ac 100644 --- a/src/EFCore/Properties/CoreStrings.resx +++ b/src/EFCore/Properties/CoreStrings.resx @@ -226,7 +226,7 @@ The type '{entityType}' cannot be marked as owned because a non-owned entity type with the same name already exists. - The shared type entity type '{entityType}' with CLR type '{type}' cannot be added to the model because a non-shared entity type with the same CLR type already exists. + The shared-type entity type '{entityType}' with CLR type '{type}' cannot be added to the model because a non-shared entity type with the same CLR type already exists. The entity type '{entityType}' with a defining navigation cannot be added to the model because an entity type with the same name already exists. @@ -253,7 +253,7 @@ The property '{property}' cannot exist on type '{entityType}' because the type is marked as shadow state while the property is not. Shadow state types can only contain shadow state properties. - The property '{1_entityType}.{0_property}' is being accessed using '{collectionMethod}', but is defined in the model as a non-collection, reference navigation. Use '{referenceMethod}' to access reference navigation properties. + The property '{1_entityType}.{0_property}' is being accessed using '{collectionMethod}', but is defined in the model as a non-collection, reference navigation. Use '{referenceMethod}' to access reference navigations. The comparer for type '{type}' cannot be used for '{entityType}.{propertyName}' because its type is '{propertyType}'. @@ -277,7 +277,7 @@ The property or navigation '{member}' cannot be added to the entity type '{entityType}' because a property or navigation with the same name already exists on entity type '{conflictingEntityType}'. - Cannot create a relationship between '{newPrincipalNavigationSpecification}' and '{newDependentNavigationSpecification}' because a relationship already exists between '{existingPrincipalNavigationSpecification}' and '{existingDependentNavigationSpecification}'. Navigation properties can only participate in a single relationship. If you want to override an existing relationship call 'Ignore' on the navigation '{newDependentNavigationSpecification}' first in 'OnModelCreating'. + Cannot create a relationship between '{newPrincipalNavigationSpecification}' and '{newDependentNavigationSpecification}' because a relationship already exists between '{existingPrincipalNavigationSpecification}' and '{existingDependentNavigationSpecification}'. Navigations can only participate in a single relationship. If you want to override an existing relationship call 'Ignore' on the navigation '{newDependentNavigationSpecification}' first in 'OnModelCreating'. cannot bind '{failedBinds}' in '{parameters}' @@ -415,7 +415,7 @@ The specified entity type '{entityType}' is invalid. It must be either the dependent entity type '{dependentType}' or the principal entity type '{principalType}'. - The specified entity types '{invalidDependentType}' and '{invalidPrincipalType}' are invalid. They should be '{dependentType}' and '{principalType}', or entity types in the same hierarchy. + The provided entity types '{invalidDependentType}' and '{invalidPrincipalType}' are invalid. Specify '{dependentType}' and '{principalType}', or entity types in the same hierarchy. Cannot use multiple context instances within a single query execution. Ensure the query uses a single context instance. @@ -433,13 +433,13 @@ An exception was thrown while attempting to evaluate the LINQ query parameter expression '{expression}'. See the inner exception for more information. - The specified field '{field}' cannot be used for the property '{entityType}.{property}' because it does not match the property name. + The specified field '{field}' cannot be used for the property '{entityType}.{property}' because it does not match the property name. Entity type properties that aren't associated with a CLR property must match the field name exactly. - Entity type '{entityType}' is defined with a single key property, but {valuesCount} values were passed to the 'DbSet.Find' method. + Entity type '{entityType}' is defined with a single key property, but {valuesCount} values were passed to the 'Find' method. - Entity type '{entityType}' is defined with a {propertiesCount}-part composite key, but {valuesCount} values were passed to the 'DbSet.Find' method. + Entity type '{entityType}' is defined with a {propertiesCount}-part composite key, but {valuesCount} values were passed to the 'Find' method. The key value at position {index} of the call to 'DbSet<{entityType}>.Find' was of type '{valueType}', which does not match the property type of '{propertyType}'. @@ -448,31 +448,31 @@ The [ForeignKey] attribute for the navigation '{navigation}' cannot be specified on the entity type '{principalType}' since it represents a one-to-many relationship. Move the [ForeignKey] attribute to a property on '{dependentType}'. - The [ForeignKey] attributes on property '{property}' and navigation '{navigation}' in entity type '{entityType}' do not point at each other. The value of the [ForeignKey] attribute on the property should be navigation name, and the value of the [ForeignKey] attribute on the navigation should be the foreign key property name. + The [ForeignKey] attributes on property '{property}' and navigation '{navigation}' in entity type '{entityType}' do not point at each other. Make sure the value of the [ForeignKey] attribute on the property matches the navigation name, and the value of the [ForeignKey] attribute on the navigation matches the foreign key property name or remove one of them. The [ForeignKey] attribute cannot be specified on the skip navigation '{entityType}'.'{navigation}'. Configure the foreign key properties in 'OnModelCreating' instead. - The number of properties specified for the foreign key {foreignKeyProperties} on entity type '{dependentType}' does not match the number of properties in the principal key {principalKey} on entity type '{principalType}'. + The number of properties specified for the foreign key {foreignKeyProperties} on entity type '{dependentType}' does not match the number of properties in the principal key {principalKeyProperties} on entity type '{principalType}'. - Cannot remove the foreign key {foreigKey} from entity type '{entityType}' because it is referenced by a skip navigation '{navigation}' on entity type '{navigationEntityType}'. All referencing skip navigation must be removed before the referenced foreign key can be removed. + Cannot remove the foreign key {foreignKeyProperties} from entity type '{entityType}' because it is referenced by a skip navigation '{navigation}' on entity type '{navigationEntityType}'. All referencing skip navigations must be removed before the referenced foreign key can be removed. The specified foreign key properties {foreignKeyProperties} are not declared on the entity type '{entityType}'. Ensure that foreign key properties are declared on the target entity type. - The property '{property}' cannot be part of a foreign key on '{entityType}' because it has a store-generated value and is contained in the key {keyProperties} defined on a base entity type '{baseEntityType}'. + The property '{property}' cannot be part of a foreign key on '{entityType}' because it has a store-generated value and is contained in the key {keyProperties} defined on a base entity type '{baseEntityType}'. Configure '{property}' with 'ValueGeneratedNever' or define the foreign key on '{entityType}' instead. - The provided principal entity key '{principalKey}' is not a key on the entity type '{principalEntityType}'. + The provided principal key {principalKeyProperties} is not a key on the entity type '{principalEntityType}'. Provide a key that's defined on the principal entity type. The foreign keys on entity type '{dependentType}' cannot target the same entity type because it is a weak entity type. - 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 {principalKey} on entity type '{principalType}'. + 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. The foreign key {foreignKeyProperties} targeting the key {keyProperties} on '{principalType}' cannot be removed from the entity type '{entityType}' because it is defined on the entity type '{otherEntityType}'. @@ -484,13 +484,13 @@ The '{methodName}' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server. - The edge cannot be added because the graph does not contain vertex '{vertex}'. + The provided edge cannot be added because the graph does not contain the vertex '{vertex}'. - The block size used for Hi-Lo value generation must be positive. When the Hi-Lo generator is backed by a SQL sequence this means that the sequence increment must be positive. + The block size used for Hi-Lo value generation is not positive. The Hi-Lo generator is usually backed by a SQL sequence and this means that the sequence increment must be positive. - The entity type '{entityType}' is part of a relationship cycle involving its primary key. + The entity type '{entityType}' is part of a relationship cycle involving its primary key {keyProperties}. This would prevent any values to be inserted without vialoating the store constraints. Review the foreign keys defined on the primary key and either remove or use other properties for at least one of them. The instance of entity type '{entityType}' cannot be tracked because another instance with the same key value for {keyProperties} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values. @@ -521,25 +521,26 @@ The Include path '{navigationName}->{inverseNavigationName}' results in a cycle. Cycles are not allowed in no-tracking queries; either use a tracking query or remove the cycle. - The entity type '{entityType}' should derive from '{baseEntityType}' to reflect the hierarchy of the corresponding CLR types. + The entity type '{entityType}' is configured as derived from '{baseEntityType}', however according to the hierarchy of the corresponding CLR types it should derive from '{clrBaseEntityType}'. Configure '{entityType}' having either '{baseEntityType}' or 'null' as the base type. - The entity type '{ownedEntityType}' is configured as owned, but the entity type '{nonOwnedEntityType}' is not. All entity types sharing a CLR type must be configured as owned in 'OnModelCreating'. + 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'. - The specified index properties {index} are not declared on the entity type '{entityType}'. Ensure that index properties are declared on the target entity type. + The specified index properties {indexProperties} are not declared on the entity type '{entityType}'. Ensure that index properties are declared on the target entity type. The index {indexProperties} cannot be removed from the entity type '{entityType}' because it is defined on the entity type '{otherEntityType}'. - The property '{property}' cannot be ignored on entity type '{entityType}' because it's declared on the base entity type '{baseEntityType}'. To exclude this property from your model, use the [NotMapped] attribute or 'EntityTypeBuilder.Ignore' on the base type in 'OnModelCreating'. + The property '{property}' cannot be ignored on entity type '{entityType}' because it's declared on the base entity type '{baseEntityType}'. To exclude this property from your model, use the [NotMapped] attribute or 'Ignore' on the base type in 'OnModelCreating'. - The property '{entityType}.{navigation}' is of an interface type ('{propertyType}'). If it is a navigation, manually configure the relationship for this property by casting it to a mapped entity type. Otherwise, ignore the property using the [NotMapped] attribute or 'EntityTypeBuilder.Ignore' in 'OnModelCreating'. + The property '{entityType}.{navigation}' is of an interface type ('{propertyType}'). If it is a navigation, manually configure the relationship for this property by casting it to a mapped entity type. Otherwise, ignore the property using the [NotMapped] attribute or 'Ignore' in 'OnModelCreating'. The entity type related to '{entityType}' cannot be determined because the specified foreign key {foreignKeyProperties} references entity type '{principalEntityType}', which is in the same hierarchy as the entity type which is declared on '{dependentEntityType}'. + Obsolete Unable to track an entity of type '{entityType}' because alternate key property '{keyProperty}' is null. If the alternate key is not used in a relationship, then consider using a unique index instead. Unique indexes may contain nulls, while alternate keys may not. @@ -548,7 +549,7 @@ The specified type '{type}' must be a non-interface reference type to be used as an entity type. - The value provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'. + The value '{value}' provided for argument '{argumentName}' must be a valid value of enum type '{enumType}'. The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, use casting ('t => ((Derived)t).MyProperty') or the 'as' operator ('t => (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see http://go.microsoft.com/fwlink/?LinkID=746393. @@ -577,10 +578,10 @@ Obsolete - The property list specified using [ForeignKey] attribute on navigation '{1_entityType}.{0_navigation}' is incorrect. The attribute value should be comma-separated list of property names. + The property list specified using [ForeignKey] attribute on navigation '{1_entityType}.{0_navigation}' is incorrect. Provide a comma-separated list of property names. - An invalid relationship has been specified using the [InverseProperty] and [ForeignKey] attributes. The navigations '{1_entityType}.{0_navigation}' and '{3_referencedEntityType}.{2_referencedNavigation}' are related by the [InverseProperty] attribute, but the [ForeignKey] attribute specified for both navigations have different values. + An invalid relationship has been specified using the [InverseProperty] and [ForeignKey] attributes. The navigations '{1_entityType}.{0_navigation}' and '{3_referencedEntityType}.{2_referencedNavigation}' are related by the [InverseProperty] attribute, but the [ForeignKey] attributes specified for both navigations have different values. Either specify the same properties or remove one of the attributes. A call was made to '{replaceService}', but Entity Framework is not building its own internal service provider. Either allow Entity Framework to build the service provider by removing the call to '{useInternalServiceProvider}', or build replacement services into the service provider before passing it to '{useInternalServiceProvider}'. @@ -589,16 +590,16 @@ The invoked method cannot be used for the entity type '{entityType}' because it does not have a primary key. - Cannot create a DbSet for '{typeName}' because it is configured as an shared type entity type. Access the entity type via the `Set` method overload that accepts an entity type name. + Cannot create a DbSet for '{typeName}' because it is configured as an shared-type entity type. Access the entity type via the 'Set' method overload that accepts an entity type name. Cannot create a DbSet for '{typeName}' because this type is not included in the model for the context. - Cannot create a DbSet for '{typeName}' because it is configured as an owned entity type and must be accessed through its owning entity type. + Cannot create a DbSet for '{typeName}' because it is configured as an owned entity type and must be accessed through its owning entity type '{ownerType}'. - Cannot create a DbSet for '{typeName}' because it is mapped to multiple entity types and should be accessed through the owning entities. + 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. Invalid {name}: {value} @@ -616,7 +617,7 @@ The '{factory}' cannot create a value generator for property '{2_entityType}.{1_property}'. Only integer properties are supported. - [InverseProperty] attributes on navigation '{1_entityType}.{0_navigation}' and on navigation '{3_referencedEntityType}.{2_referencedNavigation}' are not pointing to each other. + [InverseProperty] attributes on navigation '{1_entityType}.{0_navigation}' and on navigation '{3_referencedEntityType}.{2_referencedNavigation}' are not pointing to each other. Change the attributes to use the corresponding names or remove one of them. The navigation '{principalEntityType}.{navigation}' is not supported because it is pointing to an owned entity type '{ownedType}'. Only the ownership navigation from the entity type '{ownerType}' can point to the owned entity type. @@ -628,16 +629,16 @@ The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'. Only providers that implement 'IAsyncQueryProvider' can be used for Entity Framework asynchronous operations. - The derived type '{derivedType}' cannot have the [Key] attribute on property '{property}' since primary keys may only be declared on the root type. + The derived type '{derivedType}' cannot have the [Key] attribute on property '{property}' since primary keys may only be declared on the root type. Move the property '{property}' to '{rootType}' or remove '{rootType}' from the model by using [NotMapped] attribute or calling 'EntityTypeBuilder.Ignore' on the base type in 'OnModelCreating'. - Cannot remove key {keyProperties} from entity type '{entityType}' because it is referenced by a foreign key {foreignKeyProperties} in entity type '{dependentType}'. All foreign keys must be removed or redefined before the referenced key can be removed. + Cannot remove key {keyProperties} from entity type '{entityType}' because it is referenced by a foreign key {foreignKeyProperties} defined on entity type '{dependentType}'. Remove or change the principal key for all referencing foreign keys before removing the key. - The entity type '{entityType}' cannot be marked as keyless because it contains a key. + The entity type '{entityType}' cannot be marked as keyless because it contains a key {keyProperties}. - Unable to track an instance of type '{type}' because it does not have a primary key. Only entity types with primary keys may be tracked. + Unable to track an instance of type '{type}' because it does not have a primary key. Only entity types with a primary key may be tracked. The key {keyProperties} cannot be added to keyless type '{entityType}'. @@ -701,7 +702,7 @@ Warning CoreEventId.ConflictingKeylessAndKeyAttributesWarning string string - There are multiple relationships between '{dependentEntityType}' and '{principalEntityType}' without configured foreign key properties. This will cause Entity Framework to create shadow properties on '{dependentType}' with names dependent on the discovery order. + There are multiple relationships between '{dependentEntityType}' and '{principalEntityType}' without configured foreign key properties. This will cause Entity Framework to create shadow properties on '{dependentType}' with names dependent on the discovery order. Consider configuring the foreign key properties using the [ForeignKey] attribute or in 'OnModelCreating'. Warning CoreEventId.ConflictingShadowForeignKeysWarning string string string @@ -745,11 +746,11 @@ Warning CoreEventId.FirstWithoutOrderByAndFilterWarning - Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships as the [ForeignKey] attribute was specified on navigations on both sides. + Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships since the [ForeignKey] attribute was specified on navigations on both sides. Warning CoreEventId.ForeignKeyAttributesOnBothNavigationsWarning string string string string - Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships as the [ForeignKey] attribute was specified on properties '{dependentProperty}' and '{principalProperty}' on both sides. + Navigations '{dependentEntityType}.{dependentNavigation}' and '{principalEntityType}.{principalNavigation}' were separated into two relationships since the [ForeignKey] attribute was specified on properties '{dependentProperty}' and '{principalProperty}' on both sides. Warning CoreEventId.ForeignKeyAttributesOnBothPropertiesWarning string string string string string string @@ -777,11 +778,11 @@ Warning CoreEventId.ManyServiceProvidersCreatedWarning - There are multiple navigations ({navigations}) configured with [InverseProperty] attribute which point to the same inverse navigation '{inverseNavigation}'. + There are multiple navigations ({navigations}) configured with [InverseProperty] attribute which point to the same inverse navigation '{inverseNavigation}' therefore no relationship was configured by convention. Warning CoreEventId.MultipleInversePropertiesSameTargetWarning string string - No relationship from '{firstEntityType}' to '{secondEntityType}' has been configured by convention because there are multiple properties on one entity type {navigationProperties} that could be matched with the properties on the other entity type {inverseNavigations}. This message can be disregarded if explicit configuration has been specified in 'OnModelCreating'. + No relationship from '{firstEntityType}' to '{secondEntityType}' has been configured by convention because there are multiple properties on one entity type - {navigationProperties} that could be matched with the properties on the other entity type - {inverseNavigations}. This message can be disregarded if explicit configuration has been specified in 'OnModelCreating'. Debug CoreEventId.MultipleNavigationProperties string string string string @@ -797,7 +798,7 @@ Debug CoreEventId.NavigationLazyLoading string string - The navigation '{targetEntityType}.{inverseNavigation}' cannot be used as the inverse of '{weakEntityType}.{navigation}' because it's not the defining navigation '{definingNavigation}' + 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 @@ -813,7 +814,7 @@ Obsolete Debug CoreEventId.NonNullableReferenceOnDependent string string - The navigation '{targetEntityType}.{inverseNavigation}' cannot be used as the inverse of '{ownedEntityType}.{navigation}' because it's not the ownership navigation '{ownershipNavigation}' + The navigation '{targetEntityType}.{inverseNavigation}' specified in the [InverseProperty] attribute cannot be used as the inverse of '{ownedEntityType}.{navigation}' because it's not the ownership navigation '{ownershipNavigation}'. Warning CoreEventId.NonOwnershipInverseNavigationWarning string string string string string @@ -853,11 +854,11 @@ Warning CoreEventId.RedundantAddServicesCallWarning - The foreign key {redundantForeignKey} on entity type '{entityType} targets itself. Consider removing it since it serves no purpose. + The foreign key {redundantForeignKeyProperties} on entity type '{entityType}' targets itself. Consider removing it since it serves no purpose. Warning CoreEventId.RedundantForeignKeyWarning string string - The index {redundantIndex} was not created on entity type '{firstEntityType}' as the properties are already covered by the index {otherIndex}. + The index {redundantIndexProperties} was not created on entity type '{firstEntityType}' as the properties are already covered by the index {otherIndexProperties}. Debug CoreEventId.RedundantIndexRemoved string string string @@ -960,7 +961,7 @@ The specified field '{field}' could not be found for property '{2_entityType}.{1_property}'. - Unable to set up a many-to-many relationship between the entity types '{principalEntityType}' and '{declaringEntityType}' because one of the navigations was not specified. Please provide a navigation in the 'HasMany' call in 'OnModelCreating'. + Unable to set up a many-to-many relationship between the entity types '{principalEntityType}' and '{declaringEntityType}' because one of the navigations was not specified. Provide a navigation in the 'HasMany' call in 'OnModelCreating'. The model must be finalized before '{method}' can be used. Ensure that either 'OnModelCreating' has completed or, if using a stand-alone 'ModelBuilder', that 'FinalizeModel' has been called. @@ -972,46 +973,46 @@ The filters '{filter1}' and '{filter2}' have both been configured on the same included navigation. Only one unique filter per navigation is allowed. For more information on including related data, see http://go.microsoft.com/fwlink/?LinkID=746393. - There are multiple navigations in entity type '{entityType}' which are pointing to same set of properties using a [ForeignKey] attribute: '{propertyList}' + There are multiple navigations in entity type '{entityType}' which are pointing to same set of properties '{properties}' using a [ForeignKey] attribute: {navigations}. - The entity type '{entityType}' is the target of multiple ownership relationships. + The entity type '{entityType}' is the target of multiple ownership relationships: {navigations}. Services for database providers {storeNames} have been registered in the service provider. Only a single database provider can be registered in a service provider. If possible, ensure that Entity Framework is managing its service provider by removing the call to 'UseInternalServiceProvider'. Otherwise, consider conditionally registering the database provider, or maintaining one service provider per database provider. - The property '{keyProperty}' cannot be configured as 'ValueGeneratedOnUpdate' or 'ValueGeneratedOnAddOrUpdate' because the key value cannot be changed after the entity has been added to the store. + The property '{keyProperty}' cannot be configured as 'ValueGeneratedOnUpdate' or 'ValueGeneratedOnAddOrUpdate' because it's part of a key and its value cannot be changed after the entity has been added to the store. - The index named '{indexName}' on the entity type '{entityType}' with properties {indexPropertyList} is invalid. The property '{propertyName}' has been marked as unmapped via the [NotMapped] attribute or the 'EntityTypeBuilder.Ignore' fluent API. An index cannot use unmapped properties. + The index '{indexName}' specified via [Index] attribute on the entity type '{entityType}' with properties {indexProperties} is invalid. The property '{propertyName}' has been marked as unmapped via the [NotMapped] attribute or the 'EntityTypeBuilder.Ignore' fluent API. An index cannot use unmapped properties. - An index named '{indexName}' on entity type '{entityType}' specifies properties {indexPropertyList}, but no property with name '{propertyName}' exists on that entity type or any of its base types. + An index '{indexName}' 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 index with name {indexName} cannot be removed from the entity type '{entityType}' because no such index exists on that entity type. - The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which is an array type. Collection navigation properties cannot be arrays. + The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which is an array type. Collection navigations cannot be arrays. - The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which does not implement ICollection<{targetType}>. Collection navigation properties must implement ICollection<> of the target type. + The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' which does not implement 'ICollection<{targetType}>'. Collection navigations must implement 'ICollection<>' of the target type. - The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' for which it was not possible to create a concrete instance. Either initialize the property before use, add a public parameterless constructor to the type, or use a type which can be assigned a HashSet<> or List<>. + The type of navigation '{1_entityType}.{0_navigation}' is '{foundType}' for which it was not possible to create a concrete instance. Either initialize the property before use, add a public parameterless constructor to the type, or use a type which can be assigned a 'HashSet<>' or 'List<>'. - The collection navigation '{navigation}' cannot be added to the entity type '{entityType}' because its CLR type '{clrType}' does not implement 'IEnumerable<{targetType}>'. Collection navigation properties must implement IEnumerable<> of the related entity. + The collection navigation '{navigation}' cannot be added to the entity type '{entityType}' because its CLR type '{clrType}' does not implement 'IEnumerable<{targetType}>'. Collection navigations must implement IEnumerable<> of the related entity. - The navigation '{1_entityType}.{0_navigation}' cannot be associated with foreign key {targetFk} because it was created for foreign key {actualFk}. + The navigation '{1_entityType}.{0_navigation}' cannot be associated with foreign key {targetForeignKeyProperties} because it was created for foreign key {actualForeignKeyProperties}. The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' or '{collectionMethod}' method, but is defined in the model as a non-navigation. Use the '{propertyMethod}' method to access non-navigation properties. - The navigation '{1_entityType}.{0_navigation}' does not have a setter and no writable backing field was found or specified. Read-only collection navigation properties must be initialized before use. + The navigation '{1_entityType}.{0_navigation}' does not have a setter and no writable backing field was found or specified. Read-only collection navigations must be initialized before use. Unable to determine the relationship represented by navigation '{entityType}.{navigation}' of type '{propertyType}'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'. @@ -1029,7 +1030,7 @@ No backing field was found for property '{1_entityType}.{0_property}'. Name the backing field so that it is discovered by convention, configure the backing field to use, or use a different '{propertyAccessMode}'. - No backing field was found for property '{1_entityType}.{0_property}'. Lazy-loaded navigation properties must have backing fields. Either name the backing field so that it is discovered by convention or configure the backing field to use. + No backing field was found for property '{1_entityType}.{0_property}'. Lazy-loaded navigations must have backing fields. Either name the backing field so that it is discovered by convention or configure the backing field to use. The navigation '{navigation}' cannot be added to the entity type '{entityType}' because there is no corresponding CLR property on the underlying type and navigations properties cannot be added in shadow state. @@ -1041,7 +1042,7 @@ The navigation '{navigation}' used to define the entity type '{entityType}' is not present on '{definingEntityType}'. - Cannot set the discriminator value for entity type '{entityType}' because the root entity type '{rootEntityType}' doesn't have a discriminator property set. + Cannot set the discriminator value for entity type '{entityType}' because the root entity type '{rootEntityType}' doesn't have a discriminator property configured. The entity type '{entityType}' is part of a hierarchy, but does not have a discriminator property configured. @@ -1066,6 +1067,7 @@ There is no navigation on entity type '{entityType}' associated with the foreign key {foreignKeyProperties}. + Obsolete The entity type '{entityType}' cannot inherit from '{baseEntityType}' because '{baseEntityType}' is a shadow state entity type while '{entityType}' is not. @@ -1077,16 +1079,16 @@ Property '{entityType}.{property}' cannot be used as a key because it has type '{modelType}' and provider type '{providerType}', neither of which implement 'IComparable<T>', 'IComparable' or 'IStructuralComparable'. Make '{modelType}' implement one of these interfaces to use it as a key. - The navigation '{1_entityType}.{0_navigation}' must be configured in 'OnModelCreating' with an explicit name for the target shared type entity type, or excluded by calling 'EntityTypeBuilder.Ignore'. + The navigation '{1_entityType}.{0_navigation}' must be configured in 'OnModelCreating' with an explicit name for the target shared-type entity type, or excluded by calling 'EntityTypeBuilder.Ignore'. - The ownership by '{ownershipNavigation}' should use defining navigation '{definingNavigation}' for the owned type '{entityType}' + The entity type '{2_entityType}' owned by '{0_ownershipNavigation}' should use defining navigation '{1_definingNavigation}' for . 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. - Cannot add property '{1_entityType}.{0_property}' since there is no indexer on '{1_entityType}' taking a single argument of type '{type}'. + Cannot add indexer property '{property}' since there is no indexer on '{entityType}' taking a single argument of type assignable from '{type}'. The collection type being used for navigation '{1_entityType}.{0_navigation}' does not implement 'INotifyCollectionChanged'. Any entity type configured to use the '{changeTrackingStrategy}' change tracking strategy must use collections that implement 'INotifyCollectionChanged'. Consider using 'ObservableCollection<T>' for this. @@ -1098,7 +1100,7 @@ The foreign key {foreignKeyProperties} on the entity type '{declaringEntityType}' cannot have a required dependent end since it is not unique. - '{principalEntityType}.{principalNavigation}' cannot be configured as required since it contains a collection. + '{principalEntityType}.{principalNavigation}' cannot be configured as required since it was configured as a collection. A parameterless constructor was not found on entity type '{entityType}'. In order to create an instance of '{entityType}', Entity Framework requires that a parameterless constructor be declared. @@ -1146,7 +1148,7 @@ A tracking query is attempting to project an owned entity without a corresponding owner in its result, but owned entities cannot be tracked without their owner. Either include the owner entity in the result or make the query non-tracking using 'AsNoTracking'. - The owned entity type '{ownedType}' must be referenced from another entity type via a navigation. Add a navigation to an entity type that points at '{ownedType}'. + The entity type '{ownedType}' has been marked as owned and must be referenced from another entity type via a navigation. Add a navigation to an entity type that points at '{ownedType}' or don't configure it as owned. The DbContext of type '{contextType}' cannot be pooled because it does not have a public constructor accepting a single parameter of type DbContextOptions or has more than one constructor. @@ -1155,19 +1157,19 @@ 'OnConfiguring' cannot be used to modify DbContextOptions when DbContext pooling is enabled. - You are configuring a relationship between '{dependentEntityType}' and '{principalEntityType}', but have specified a foreign key targeting '{entityType}'. The foreign key must target a type that is part of the relationship. + You are configuring a relationship between '{dependentEntityType}' and '{principalEntityType}', but have specified a principal key on '{entityType}'. The foreign key must target a type that is part of the relationship. - The entity type '{entityType}' cannot be on the principal end of the relationship between '{firstNavigationSpecification}' and '{secondNavigationSpecification}'. The principal entity type must have a key. + The keyless entity type '{entityType}' cannot be on the principal end of the relationship between '{firstNavigationSpecification}' and '{secondNavigationSpecification}'. The principal entity type must have a key. - The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' is not supported because the owned entity type '{ownedType}' cannot be on the principal side of a non-ownership relationship. + The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' is not supported because the owned entity type '{ownedType}' cannot be on the principal side of a non-ownership relationship. Remove the relationship or configure the foreign key to be on '{ownedType}'. '{property}' cannot be used as a property on entity type '{entityType}' because it is configured as a navigation. - The indexer property '{property}' cannot be added to type '{entityType}' because the CLR type contains a member with the same name. + The indexer property '{property}' cannot be added to type '{entityType}' because the CLR type contains a member with the same name. Specify a different name or configure '{property}' as a non-indexer property. The property '{1_entityType}.{0_property}' contains null, but the property is marked as required. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values. @@ -1188,7 +1190,7 @@ The property '{property}' cannot be removed from entity type '{entityType}' because it is being used in the key {keyProperties}. All containing keys must be removed or redefined before the property can be removed. - The property '{1_entityType}.{0_property}' is being accessed using the '{propertyMethod}' method, but is defined in the model as a navigation. Use either the '{referenceMethod}' or '{collectionMethod}' method to access navigation properties. + The property '{1_entityType}.{0_property}' is being accessed using the '{propertyMethod}' method, but is defined in the model as a navigation. Use either the '{referenceMethod}' or '{collectionMethod}' method to access navigations. The EF.Property<T> method may only be used within Entity Framework LINQ queries. @@ -1212,10 +1214,10 @@ The property '{property}' cannot be added to type '{entityType}' because the type of the corresponding CLR property or field '{clrType}' does not match the specified type '{propertyType}'. - The CLR property '{property}' cannot be added to entity type '{entityType}' because it is declared on the CLR type '{clrType}'. + The property '{property}' cannot be added to entity type '{entityType}' because it is declared on the CLR type '{clrType}'. - The property '{property}' cannot be added to type '{entityType}' because the name of the given CLR property or field '{clrName}' is different. + The property '{property}' cannot be added to entity type '{entityType}' because it doesn't match the name of the provided CLR property or field '{clrName}'. Use the same name or specify a different CLR member. The property '{property}' cannot be removed from the entity type '{entityType}' because it is declared on the entity type '{otherEntityType}'. @@ -1224,7 +1226,7 @@ The 'InitializeStateManager' method has been called multiple times on the current query context. This method is intended to be called only once before query enumeration starts. - The materialization condition passed for entity shaper of entity type '{entityType}' is not of the correct shape. A materialization condition must be a 'LambdaExpression' of 'Func<ValueBuffer, IEntityType>' + The materialization condition passed for entity shaper of entity type '{entityType}' is not of the correct shape. A materialization condition must be a 'LambdaExpression' of 'Func<ValueBuffer, IEntityType>'. Processing of the LINQ expression '{expression}' by '{visitor}' failed. This may indicate either a bug or a limitation in Entity Framework. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information. @@ -1251,16 +1253,16 @@ An attempt was made to use the model while it was being created. A DbContext instance cannot be used inside 'OnModelCreating' in any way that makes use of the model that is being created. - The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' with foreign key properties {foreignKeyPropertiesWithTypes} cannot target the primary key {primaryKeyPropertiesWithTypes} because it is not compatible. Configure a principal key or a set of compatible foreign key properties for this relationship. + The relationship from '{referencingEntityTypeOrNavigation}' to '{referencedEntityTypeOrNavigation}' with foreign key properties {foreignKeyPropertiesWithTypes} cannot target the primary key {primaryKeyPropertiesWithTypes} because it is not compatible. Configure a principal key or a set of foreign key properties with compatible types for this relationship. - The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' method, but is defined in the model as a collection navigation. Use the '{collectionMethod}' method to access collection navigation properties. + The property '{1_entityType}.{0_property}' is being accessed using the '{referenceMethod}' method, but is defined in the model as a collection navigation. Use the '{collectionMethod}' method to access collection navigations. The navigation '{1_entityType}.{0_navigation}' cannot have 'IsLoaded' set to false because the referenced entity is non-null and is therefore loaded. - The principal and dependent ends of the relationship cannot be inverted once foreign key or principal key properties have been specified. + The principal and dependent ends of the relationship cannot be changed once foreign key or principal key properties have been specified. Remove the conflicting configuration. The association between entity types '{firstType}' and '{secondType}' has been severed, but the relationship is either marked as required or is implicitly required because the foreign key is not nullable. If the dependent/child entity should be deleted when a required relationship is severed, configure the relationship to use cascade deletes. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values. @@ -1293,10 +1295,10 @@ The seed entity for entity type '{entityType}' cannot be added because another seed entity with the key value '{keyValue}' has already been added. - The seed entity for entity type '{entityType}' cannot be added because the value provided for the property '{property}' is not of type '{type}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the involved property values. + The seed entity for entity type '{entityType}' cannot be added because the value provided for the property '{property}' is not compatible with the property type '{type}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the involved property value. - The seed entity for entity type '{entityType}' cannot be added because the value '{value}' provided for the property '{property}' is not of type '{type}'. + The seed entity for entity type '{entityType}' cannot be added because the value '{value}' provided for the property '{property}' is not compatible with the property type '{type}'. The seed entity for entity type '{entityType}' cannot be added because no value was provided for the required property '{property}'. @@ -1311,7 +1313,7 @@ The seed entity for entity type '{entityType}' cannot be added because a non-zero value is required for property '{property}'. Consider providing a negative value to avoid collisions with non-seed data. - A relationship cannot be established from property '{1_entityType}.{0_property}' to property '{3_referencedEntityType}.{2_referencedProperty}'. Check the values in the [InverseProperty] attribute to ensure relationship definitions are unique and reference from one navigation to its corresponding inverse navigation. + The inverse for the navigation '{entityType}.{property}' cannot be the same navigation. Change the value in the [InverseProperty] attribute to a different navigation. To show additional information call 'DbContextOptionsBuilder.EnableSensitiveDataLogging'. @@ -1335,10 +1337,10 @@ Unable to translate set operation since both operands have different 'Include' operations. Consider having same 'Include' applied on both sides. - The entity type '{entityType}' is in shadow state. A valid model requires all entity types to have corresponding CLR type. + The entity type '{entityType}' is in shadow state. A valid model requires all entity types to have a corresponding CLR type. - The shared type entity type '{entityType}' cannot have a base type. + The shared-type entity type '{entityType}' cannot have a base type. A call was made to '{optionCall}' that changed an option that must be constant within a service provider, but Entity Framework is not building its own internal service provider. Either allow Entity Framework to build the service provider by removing the call to '{useInternalServiceProvider}', or ensure that the configuration for '{optionCall}' does not change for all uses of a given service provider passed to '{useInternalServiceProvider}'. @@ -1347,28 +1349,28 @@ An attempt was made to register an instance for the '{scope}' service '{service}'. Instances can only be registered for 'Singleton' services. - The foreign key {foreignKeyProperties} cannot be set for the skip navigation '{navigation}' as it uses the join entity type '{joinType}' while the inverse skip navigation '{inverse}' is using the join entity type '{inverseJoinType}'. The inverse navigation must use the same join entity type. + The foreign key {foreignKeyProperties} cannot be set for the skip navigation '{navigation}' as it uses the join entity type '{joinType}' while the inverse skip navigation '{inverse}' is associated with a foreign key using the join entity type '{inverseJoinType}'. The inverse navigation must use the same join entity type. The skip navigation '{inverse}' using the join entity type '{inverseJoinType}' cannot be set as the inverse of '{navigation}', which uses the join entity type '{joinType}'. The inverse navigation must use the same join entity type. - The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{2_entityType}.{1_navigation}' because it is expected to be on the dependent entity type '{dependentEntityType}'. + The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{entityType}.{navigation}' because it is declared on the entity type '{dependentEntityType}', but a foreign key on '{entityType}' is expected. - The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{2_entityType}.{1_navigation}' because it is expected to be on the principal entity type '{principalEntityType}'. + The foreign key {foreignKeyProperties} cannot be used for the skip navigation '{entityType}.{navigation}' because it is declared on the entity type '{entityType}', but a foreign key on '{principalEntityType}' is expected. - The skip navigation '{skipNavigation}' cannot be removed because it is set as the inverse of the skip navigation '{inverseSkipNavigation}' on '{referencingEntityType}'. All referencing skip navigations must be removed before this skip navigation can be removed. + The skip navigation '{entityType}.{skipNavigation}' cannot be removed because it is configured as the inverse of the skip navigation '{referencingEntityType}.{inverseSkipNavigation}'. All referencing skip navigations must be removed before this skip navigation can be removed. The skip navigation '{1_entityType}.{0_navigation}' doesn't have a foreign key associated with it. Every skip navigation must have a configured foreign key. - The skip navigation '{1_entityType}.{0_navigation}' doesn't have an inverse navigation configured. Every skip navigation should must an inverse skip navigation. + The skip navigation '{1_entityType}.{0_navigation}' doesn't have an inverse navigation configured. Every skip navigation should have an inverse skip navigation. - The skip navigation '{1_entityType}.{0_navigation}' is not a collection. Only collection skip navigation properties are currently supported. + The skip navigation '{1_entityType}.{0_navigation}' is not a collection. Only collection skip navigations are currently supported. The skip navigation '{inverse}' declared on the entity type '{inverseEntityType}' cannot be set as the inverse of '{navigation}', which targets '{targetEntityType}'. The inverse navigation should be declared on the target entity type. @@ -1398,13 +1400,13 @@ The LINQ expression '{expression}' could not be translated. Additional information: {details} Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information. - The type '{type}' is not been configured as a shared type in the model. Before calling 'UsingEntity', please mark the type as shared or add the entity type in the model as a shared entity. + The type '{type}' has not been configured as a shared type in the model. Before calling 'UsingEntity' add the entity type in the model as a shared entity. Unable to materialize entity instance of type '{entityType}'. No discriminators matched the discriminator value '{discriminator}'. - Unable to set IsUnique to '{isUnique}' on the relationship underlying the navigation '{2_entityType}.{1_navigationName}' because the navigation has the opposite multiplicity. + Unable to set 'IsUnique' to '{isUnique}' on the relationship associated with the navigation '{2_entityType}.{1_navigationName}' because the navigation has the opposite multiplicity. Unhandled expression node type '{nodeType}'. @@ -1422,10 +1424,10 @@ The value of '{entityType}.{property}' is unknown when attempting to save changes. This is because the property is also part of a foreign key for which the principal entity in the relationship is not known. - The unnamed index on the entity type '{entityType}' with properties {indexPropertyList} is invalid. The property '{propertyName}' was marked as unmapped by [NotMapped] attribute or 'Ignore()' in 'OnModelCreating'. An index cannot use unmapped properties. + The unnamed index specified via [Index] attribute on the entity type '{entityType}' with properties {indexProperties} is invalid. The property '{propertyName}' was marked as unmapped by [NotMapped] attribute or 'Ignore()' in 'OnModelCreating'. An index cannot use unmapped properties. - An unnamed index on the entity type '{entityType}' specifies properties {indexPropertyList}, but no property with name '{propertyName}' exists on that entity type or any of its base types. + 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. diff --git a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs index 5d093a98068..3770ce68fe6 100644 --- a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs +++ b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs @@ -377,7 +377,7 @@ public virtual void Detects_shared_table_root_cycle() modelBuilder.Entity().ToTable("Table"); VerifyError( - CoreStrings.IdentifyingRelationshipCycle(nameof(A)), + CoreStrings.IdentifyingRelationshipCycle(nameof(A), "{'Id'}"), modelBuilder.Model); } diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs index 7314a42d9bc..2f36781be2a 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs @@ -321,7 +321,7 @@ public virtual void Detects_relationship_cycle() modelBuilder.Entity().HasOne().WithOne().HasForeignKey(a => a.Id).HasPrincipalKey(b => b.Id).IsRequired(); VerifyError( - CoreStrings.IdentifyingRelationshipCycle(nameof(A)), + CoreStrings.IdentifyingRelationshipCycle(nameof(A), "{'Id'}"), modelBuilder.Model); } @@ -513,7 +513,7 @@ public virtual void Detects_skipped_base_type() var entityF = model.AddEntityType(typeof(F)); SetBaseType(entityF, entityA); - VerifyError(CoreStrings.InconsistentInheritance(nameof(F), nameof(D)), model); + VerifyError(CoreStrings.InconsistentInheritance(nameof(F), nameof(A), nameof(D)), model); } [ConditionalFact] @@ -706,7 +706,7 @@ public virtual void Detects_entity_type_with_multiple_ownerships() ownedTypeBuilder.Ignore(nameof(ReferencedEntity.SampleEntityId), ConfigurationSource.Explicit); VerifyError( - CoreStrings.MultipleOwnerships(nameof(ReferencedEntity)), + CoreStrings.MultipleOwnerships(nameof(ReferencedEntity), "'SampleEntity.ReferencedEntity', 'SampleEntity.'"), modelBuilder.Metadata); } diff --git a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs index 5f1a94fb5aa..db579114979 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs @@ -431,7 +431,7 @@ public void InversePropertyAttribute_throws_if_self_navigation() Assert.Equal( CoreStrings.SelfReferencingNavigationWithInverseProperty( - "AnotherEntity", nameof(SelfReferencingEntity), "AnotherEntity", nameof(SelfReferencingEntity)), + nameof(SelfReferencingEntity), nameof(SelfReferencingEntity.AnotherEntity)), Assert.Throws( () => RunEntityTypeConventions(entityTypeBuilder)).Message); } @@ -848,7 +848,7 @@ public void ForeignKeyAttribute_throws_when_same_set_of_properties_are_pointed_b var navigation = relationshipBuilder.Metadata.DependentToPrincipal; Assert.Equal( - CoreStrings.MultipleNavigationsSameFk(typeof(MultipleNavigationsSameFk).Name, "CommonFkProperty"), + CoreStrings.MultipleNavigationsSameFk(typeof(MultipleNavigationsSameFk).Name, "CommonFkProperty", "'One', 'Two'"), Assert.Throws( () => useNavigation ? RunForeignKeyAttributeConvention(relationshipBuilder, navigation) diff --git a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs index 01120e2dfc0..65d5868a819 100644 --- a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs @@ -216,7 +216,8 @@ public void KeyAttribute_throws_when_setting_key_in_derived_type() var propertyBuilder = derivedEntityTypeBuilder.Property(typeof(int), "Number", ConfigurationSource.Explicit); Assert.Equal( - CoreStrings.KeyAttributeOnDerivedEntity(derivedEntityTypeBuilder.Metadata.DisplayName(), propertyBuilder.Metadata.Name), + CoreStrings.KeyAttributeOnDerivedEntity( + derivedEntityTypeBuilder.Metadata.DisplayName(), propertyBuilder.Metadata.Name, baseEntityType.DisplayName()), Assert.Throws(() => Validate(derivedEntityTypeBuilder)) .Message); } diff --git a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs index b00463cc769..4cebcad8929 100644 --- a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs @@ -124,7 +124,7 @@ public void Constructor_throws_when_principal_and_dependent_property_types_do_no new[] { property2, property3 }); Assert.Equal( - CoreStrings.ForeignKeyTypeMismatch("{'P1', 'P2'}", "D", "{'Id1', 'Id2'}", "P"), + CoreStrings.ForeignKeyTypeMismatch("{'P1' : int, 'P2' : string}", "D", "{'Id1' : int, 'Id2' : int}", "P"), Assert.Throws( () => dependentEntityType.AddForeignKey( new[] { dependentProperty1, dependentProperty2 }, principalEntityType.FindPrimaryKey(), principalEntityType)) @@ -589,10 +589,12 @@ public void Can_find_targets_for_non_hierarchical_foreign_keys() Assert.Equal(new[] { fk.DependentToPrincipal }, fk.FindNavigationsTo(fk.PrincipalEntityType)); Assert.Equal(new[] { fk.PrincipalToDependent }, fk.FindNavigationsTo(fk.DeclaringEntityType)); +#pragma warning disable CS0612 // Type or member is obsolete Assert.Same(fk.DeclaringEntityType, fk.ResolveEntityTypeInHierarchy(fk.DeclaringEntityType)); Assert.Same(fk.PrincipalEntityType, fk.ResolveEntityTypeInHierarchy(fk.PrincipalEntityType)); Assert.Same(fk.PrincipalEntityType, fk.ResolveOtherEntityTypeInHierarchy(fk.DeclaringEntityType)); Assert.Same(fk.DeclaringEntityType, fk.ResolveOtherEntityTypeInHierarchy(fk.PrincipalEntityType)); +#pragma warning restore CS0612 // Type or member is obsolete Assert.Equal(new[] { fk.PrincipalToDependent }, fk.FindNavigationsFromInHierarchy(fk.PrincipalEntityType)); Assert.Equal(new[] { fk.DependentToPrincipal }, fk.FindNavigationsFromInHierarchy(fk.DeclaringEntityType)); Assert.Equal(new[] { fk.DependentToPrincipal }, fk.FindNavigationsToInHierarchy(fk.PrincipalEntityType)); @@ -618,10 +620,12 @@ public void Can_find_targets_for_same_base_foreign_keys() Assert.Same(fk.DependentToPrincipal, fk.FindNavigationsTo(fk.PrincipalEntityType).SingleOrDefault()); Assert.Same(fk.PrincipalToDependent, fk.FindNavigationsTo(fk.DeclaringEntityType).SingleOrDefault()); +#pragma warning disable CS0612 // Type or member is obsolete Assert.Same(fk.DeclaringEntityType, fk.ResolveEntityTypeInHierarchy(fk.DeclaringEntityType)); Assert.Same(fk.PrincipalEntityType, fk.ResolveEntityTypeInHierarchy(fk.PrincipalEntityType)); Assert.Same(fk.PrincipalEntityType, fk.ResolveOtherEntityTypeInHierarchy(fk.DeclaringEntityType)); Assert.Same(fk.DeclaringEntityType, fk.ResolveOtherEntityTypeInHierarchy(fk.PrincipalEntityType)); +#pragma warning restore CS0612 // Type or member is obsolete Assert.Same(fk.PrincipalToDependent, fk.FindNavigationsFromInHierarchy(fk.PrincipalEntityType).SingleOrDefault()); Assert.Same(fk.DependentToPrincipal, fk.FindNavigationsFromInHierarchy(fk.DeclaringEntityType).SingleOrDefault()); Assert.Same(fk.DependentToPrincipal, fk.FindNavigationsToInHierarchy(fk.PrincipalEntityType).SingleOrDefault()); @@ -652,10 +656,12 @@ public void Can_find_targets_for_same_base_foreign_keys() derivedDependent.DisplayName(), fk.DeclaringEntityType.DisplayName(), fk.PrincipalEntityType.DisplayName()), Assert.Throws(() => fk.FindNavigationsTo(derivedDependent)).Message); +#pragma warning disable CS0612 // Type or member is obsolete Assert.Same(fk.DeclaringEntityType, fk.ResolveEntityTypeInHierarchy(derivedDependent)); Assert.Same(fk.PrincipalEntityType, fk.ResolveEntityTypeInHierarchy(derivedPrincipal)); Assert.Same(fk.PrincipalEntityType, fk.ResolveOtherEntityTypeInHierarchy(derivedDependent)); Assert.Same(fk.DeclaringEntityType, fk.ResolveOtherEntityTypeInHierarchy(derivedPrincipal)); +#pragma warning restore CS0612 // Type or member is obsolete Assert.Equal(new[] { fk.PrincipalToDependent }.Where(n => n != null), fk.FindNavigationsFromInHierarchy(derivedPrincipal)); Assert.Equal(new[] { fk.DependentToPrincipal }.Where(n => n != null), fk.FindNavigationsFromInHierarchy(derivedDependent)); Assert.Equal(new[] { fk.DependentToPrincipal }.Where(n => n != null), fk.FindNavigationsToInHierarchy(derivedPrincipal)); @@ -709,6 +715,7 @@ public void Can_finding_targets_for_same_hierarchy_foreign_keys() Assert.Same(fk.DependentToPrincipal, fk.FindNavigationsTo(fk.PrincipalEntityType).SingleOrDefault()); Assert.Same(fk.PrincipalToDependent, fk.FindNavigationsTo(fk.DeclaringEntityType).SingleOrDefault()); +#pragma warning disable CS0612 // Type or member is obsolete Assert.Equal( CoreStrings.IntraHierarchicalAmbiguousTargetEntityType( fk.DeclaringEntityType.DisplayName(), fk.Properties.Format(), fk.PrincipalEntityType.DisplayName(), @@ -730,6 +737,7 @@ public void Can_finding_targets_for_same_hierarchy_foreign_keys() fk.PrincipalEntityType.DisplayName(), fk.Properties.Format(), fk.PrincipalEntityType.DisplayName(), fk.DeclaringEntityType.DisplayName()), Assert.Throws(() => fk.ResolveOtherEntityTypeInHierarchy(fk.PrincipalEntityType)).Message); +#pragma warning restore CS0612 // Type or member is obsolete Assert.Equal( new[] { fk.PrincipalToDependent, fk.DependentToPrincipal }.Where(n => n != null), @@ -778,6 +786,7 @@ public void Finding_targets_throws_for_entity_types_not_in_the_relationship() unrelatedType.DisplayName(), fk.DeclaringEntityType.DisplayName(), fk.PrincipalEntityType.DisplayName()), Assert.Throws(() => fk.FindNavigationsTo(unrelatedType)).Message); +#pragma warning disable CS0612 // Type or member is obsolete Assert.Equal( CoreStrings.EntityTypeNotInRelationship( unrelatedType.DisplayName(), fk.DeclaringEntityType.DisplayName(), fk.PrincipalEntityType.DisplayName()), @@ -795,6 +804,7 @@ public void Finding_targets_throws_for_entity_types_not_in_the_relationship() CoreStrings.EntityTypeNotInRelationship( unrelatedType.DisplayName(), fk.DeclaringEntityType.DisplayName(), fk.PrincipalEntityType.DisplayName()), Assert.Throws(() => fk.ResolveOtherEntityTypeInHierarchy(unrelatedType)).Message); +#pragma warning restore CS0612 // Type or member is obsolete Assert.Equal( CoreStrings.EntityTypeNotInRelationship( diff --git a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs index 6965288d4d0..d5cd96589df 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs @@ -1225,10 +1225,9 @@ public void HasNoKey_can_override_lower_or_equal_source_key() Assert.NotEmpty(entityType.GetKeys()); Assert.Equal( - CoreStrings.KeylessTypeExistingKey(nameof(Order)), + CoreStrings.KeylessTypeExistingKey(nameof(Order), "{'CustomerId'}"), Assert.Throws( - () => - entityBuilder.HasNoKey(ConfigurationSource.Explicit)).Message); + () => entityBuilder.HasNoKey(ConfigurationSource.Explicit)).Message); Assert.NotEmpty(entityType.GetKeys()); } diff --git a/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs b/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs index ab3b51fe572..7efa325e3f0 100644 --- a/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs @@ -85,7 +85,7 @@ public void Setting_foreign_key_to_skip_navigation_with_wrong_dependent_throws() Assert.Equal( CoreStrings.SkipNavigationForeignKeyWrongDependentType( - "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(Order.Products), nameof(Order), nameof(OrderProduct)), + "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(Order), nameof(Order.Products), nameof(OrderProduct)), Assert.Throws(() => navigation.SetForeignKey(orderProductForeignKey)).Message); } @@ -106,7 +106,7 @@ public void Setting_foreign_key_to_skip_navigation_with_wrong_principal_throws() Assert.Equal( CoreStrings.SkipNavigationForeignKeyWrongPrincipalType( - "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(OrderProduct.Order), nameof(OrderProduct), nameof(Order)), + "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(OrderProduct), nameof(OrderProduct.Order), nameof(Order)), Assert.Throws(() => navigation.SetForeignKey(orderProductForeignKey)).Message); } @@ -178,7 +178,7 @@ public void Can_set_inverse() Assert.Equal(ConfigurationSource.Explicit, ((IConventionSkipNavigation)ordersNavigation).GetInverseConfigurationSource()); Assert.Equal( - CoreStrings.SkipNavigationInUseBySkipNavigation(nameof(Order.Products), nameof(Product.Orders), nameof(Product)), + CoreStrings.SkipNavigationInUseBySkipNavigation(nameof(Order), nameof(Order.Products), nameof(Product), nameof(Product.Orders)), Assert.Throws(() => orderEntity.RemoveSkipNavigation(productsNavigation)).Message); productsNavigation.SetInverse(null); diff --git a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs index 9d8d1ad26b6..ca84ca30f91 100644 --- a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs @@ -2786,7 +2786,7 @@ public virtual void Throws_if_specified_FK_types_do_not_match() modelBuilder.Ignore(); Assert.Equal( - CoreStrings.ForeignKeyTypeMismatch("{'GuidProperty'}", nameof(CustomerDetails), "{'Id'}", nameof(Customer)), + CoreStrings.ForeignKeyTypeMismatch("{'GuidProperty' : Guid}", nameof(CustomerDetails), "{'Id' : int}", nameof(Customer)), Assert.Throws( () => modelBuilder .Entity().HasOne(c => c.Details).WithOne(d => d.Customer) @@ -2826,7 +2826,7 @@ public virtual void Throws_if_specified_PK_types_do_not_match() modelBuilder.Ignore(); Assert.Equal( - CoreStrings.ForeignKeyTypeMismatch("{'GuidProperty'}", nameof(CustomerDetails), "{'Id'}", nameof(Customer)), + CoreStrings.ForeignKeyTypeMismatch("{'GuidProperty' : Guid}", nameof(CustomerDetails), "{'Id' : int}", nameof(Customer)), Assert.Throws( () => modelBuilder @@ -3608,7 +3608,7 @@ public virtual void Throws_if_multiple_navigations_are_pointing_to_same_foreign_ { var modelBuilder = CreateModelBuilder(); Assert.Equal( - CoreStrings.MultipleNavigationsSameFk(typeof(Zeta).Name, "CommonFkProperty"), + CoreStrings.MultipleNavigationsSameFk(typeof(Zeta).Name, "CommonFkProperty", "'AlphaOne', 'AlphaTwo'"), Assert.Throws(() => modelBuilder.Entity().HasOne().WithOne()).Message); }