diff --git a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs index 92716622a4c..e40951abb20 100644 --- a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs +++ b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs @@ -231,7 +231,7 @@ public static bool AreCompatible( public virtual InternalCheckConstraintBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(ModelName)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/DbFunction.cs b/src/EFCore.Relational/Metadata/Internal/DbFunction.cs index 0eed55bcd60..32232a7c01e 100644 --- a/src/EFCore.Relational/Metadata/Internal/DbFunction.cs +++ b/src/EFCore.Relational/Metadata/Internal/DbFunction.cs @@ -156,7 +156,7 @@ public static string GetFunctionName(MethodInfo methodInfo) public virtual InternalDbFunctionBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(ModelName)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs b/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs index 559a6e84fd7..664229ec230 100644 --- a/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs +++ b/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs @@ -52,7 +52,7 @@ public DbFunctionParameter( public virtual InternalDbFunctionParameterBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/EntityTypeMappingFragment.cs b/src/EFCore.Relational/Metadata/Internal/EntityTypeMappingFragment.cs index 437ebffadbf..d37388ba95c 100644 --- a/src/EFCore.Relational/Metadata/Internal/EntityTypeMappingFragment.cs +++ b/src/EFCore.Relational/Metadata/Internal/EntityTypeMappingFragment.cs @@ -47,7 +47,8 @@ public EntityTypeMappingFragment( public virtual InternalEntityTypeMappingFragmentBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel( + StoreObject.DisplayName())); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalPropertyOverrides.cs b/src/EFCore.Relational/Metadata/Internal/RelationalPropertyOverrides.cs index 9dde0563fdf..fea560ea1c9 100644 --- a/src/EFCore.Relational/Metadata/Internal/RelationalPropertyOverrides.cs +++ b/src/EFCore.Relational/Metadata/Internal/RelationalPropertyOverrides.cs @@ -73,7 +73,8 @@ public override bool IsReadOnly public virtual InternalRelationalPropertyOverridesBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel( + $"{Property.Name} - {StoreObject.DisplayName()}")); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/Sequence.cs b/src/EFCore.Relational/Metadata/Internal/Sequence.cs index eb790f0db45..97f97c7bd8b 100644 --- a/src/EFCore.Relational/Metadata/Internal/Sequence.cs +++ b/src/EFCore.Relational/Metadata/Internal/Sequence.cs @@ -237,7 +237,7 @@ public static Sequence AddSequence( public virtual InternalSequenceBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs index 57d52f5a6c4..268c02b6a20 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs @@ -59,7 +59,7 @@ public StoredProcedure( public virtual InternalStoredProcedureBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs index eb4f288abb4..4bcba9c28fc 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureParameter.cs @@ -58,7 +58,7 @@ public StoredProcedureParameter( public virtual InternalStoredProcedureParameterBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs index ae9bcce195f..3e744a03001 100644 --- a/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs +++ b/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs @@ -46,7 +46,7 @@ public StoredProcedureResultColumn( public virtual InternalStoredProcedureResultColumnBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore.Relational/Storage/RelationalCommandParameterObject.cs b/src/EFCore.Relational/Storage/RelationalCommandParameterObject.cs index 45f55b514d0..b03e2ee80f7 100644 --- a/src/EFCore.Relational/Storage/RelationalCommandParameterObject.cs +++ b/src/EFCore.Relational/Storage/RelationalCommandParameterObject.cs @@ -16,7 +16,7 @@ namespace Microsoft.EntityFrameworkCore.Storage; /// See Implementation of database providers and extensions /// for more information and examples. /// -public readonly struct RelationalCommandParameterObject +public readonly record struct RelationalCommandParameterObject { /// /// diff --git a/src/EFCore/Metadata/Internal/ComplexProperty.cs b/src/EFCore/Metadata/Internal/ComplexProperty.cs index 183703ac1ae..1b3e0c811f8 100644 --- a/src/EFCore/Metadata/Internal/ComplexProperty.cs +++ b/src/EFCore/Metadata/Internal/ComplexProperty.cs @@ -54,7 +54,7 @@ public ComplexProperty( public virtual InternalComplexPropertyBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/ComplexType.cs b/src/EFCore/Metadata/Internal/ComplexType.cs index ac6390cdea2..b906a8a1c5b 100644 --- a/src/EFCore/Metadata/Internal/ComplexType.cs +++ b/src/EFCore/Metadata/Internal/ComplexType.cs @@ -68,7 +68,7 @@ public ComplexType( public new virtual InternalComplexTypeBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/ElementType.cs b/src/EFCore/Metadata/Internal/ElementType.cs index da6e1cc5ee1..df5941febc8 100644 --- a/src/EFCore/Metadata/Internal/ElementType.cs +++ b/src/EFCore/Metadata/Internal/ElementType.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; +using System.Xml.Linq; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage.Json; @@ -80,7 +81,7 @@ public virtual void SetConfigurationSource(ConfigurationSource configurationSour public virtual InternalElementTypeBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(ClrType.ShortDisplayName())); } /// diff --git a/src/EFCore/Metadata/Internal/EntityType.cs b/src/EFCore/Metadata/Internal/EntityType.cs index 7e498e281e4..98ac9ab9f09 100644 --- a/src/EFCore/Metadata/Internal/EntityType.cs +++ b/src/EFCore/Metadata/Internal/EntityType.cs @@ -151,7 +151,7 @@ public EntityType( public new virtual InternalEntityTypeBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(DisplayName())); } /// diff --git a/src/EFCore/Metadata/Internal/ForeignKey.cs b/src/EFCore/Metadata/Internal/ForeignKey.cs index a201ac836b9..1d0d35110ed 100644 --- a/src/EFCore/Metadata/Internal/ForeignKey.cs +++ b/src/EFCore/Metadata/Internal/ForeignKey.cs @@ -116,7 +116,8 @@ public ForeignKey( public virtual InternalForeignKeyBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel( + Property.Format(Properties.Select(p => p.Name)))); } /// diff --git a/src/EFCore/Metadata/Internal/Index.cs b/src/EFCore/Metadata/Internal/Index.cs index 966ba49aead..d8c7dcc6ee1 100644 --- a/src/EFCore/Metadata/Internal/Index.cs +++ b/src/EFCore/Metadata/Internal/Index.cs @@ -93,7 +93,8 @@ public Index( public virtual InternalIndexBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel( + Property.Format(Properties.Select(p => p.Name)))); } /// diff --git a/src/EFCore/Metadata/Internal/Key.cs b/src/EFCore/Metadata/Internal/Key.cs index 866f3df6c71..95a4d4697e6 100644 --- a/src/EFCore/Metadata/Internal/Key.cs +++ b/src/EFCore/Metadata/Internal/Key.cs @@ -66,7 +66,8 @@ public virtual EntityType DeclaringEntityType public virtual InternalKeyBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel( + Property.Format(Properties.Select(p => p.Name)))); } /// diff --git a/src/EFCore/Metadata/Internal/Navigation.cs b/src/EFCore/Metadata/Internal/Navigation.cs index c01d009a846..0ede23739aa 100644 --- a/src/EFCore/Metadata/Internal/Navigation.cs +++ b/src/EFCore/Metadata/Internal/Navigation.cs @@ -77,7 +77,7 @@ public virtual object? Sentinel public virtual InternalNavigationBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/Property.cs b/src/EFCore/Metadata/Internal/Property.cs index d87af29aa5e..df99f3867c1 100644 --- a/src/EFCore/Metadata/Internal/Property.cs +++ b/src/EFCore/Metadata/Internal/Property.cs @@ -63,7 +63,7 @@ public Property( public virtual InternalPropertyBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/ServiceProperty.cs b/src/EFCore/Metadata/Internal/ServiceProperty.cs index b133d9c2d26..f4a589f9332 100644 --- a/src/EFCore/Metadata/Internal/ServiceProperty.cs +++ b/src/EFCore/Metadata/Internal/ServiceProperty.cs @@ -78,7 +78,7 @@ public override TypeBase DeclaringType public virtual InternalServicePropertyBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/SkipNavigation.cs b/src/EFCore/Metadata/Internal/SkipNavigation.cs index c47bf47e2e1..5b56e1a6fc5 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigation.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigation.cs @@ -85,7 +85,7 @@ public override Type ClrType public virtual InternalSkipNavigationBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name)); } /// diff --git a/src/EFCore/Metadata/Internal/Trigger.cs b/src/EFCore/Metadata/Internal/Trigger.cs index b70f749a1ca..639b219f270 100644 --- a/src/EFCore/Metadata/Internal/Trigger.cs +++ b/src/EFCore/Metadata/Internal/Trigger.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Xml.Linq; + namespace Microsoft.EntityFrameworkCore.Metadata.Internal; /// @@ -42,7 +44,7 @@ public Trigger( public virtual InternalTriggerBuilder Builder { [DebuggerStepThrough] - get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel); + get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(ModelName)); } /// diff --git a/src/EFCore/Properties/CoreStrings.Designer.cs b/src/EFCore/Properties/CoreStrings.Designer.cs index 6a2efa2891f..3475c01febc 100644 --- a/src/EFCore/Properties/CoreStrings.Designer.cs +++ b/src/EFCore/Properties/CoreStrings.Designer.cs @@ -131,7 +131,7 @@ public static string AttributeNotOnEntityTypeProperty(object? attribute, object? attribute, type, propertyName); /// - /// Cycle detected while auto-including navigations: {cycleNavigations}. To fix this issue, either don't configure at least one navigation in the cycle as auto included in `OnModelCreating` or call 'IgnoreAutoInclude' method on the query. + /// Cycle detected while auto-including navigations: {cycleNavigations}. To fix this issue, either don't configure at least one navigation in the cycle as auto included in 'OnModelCreating' or call 'IgnoreAutoInclude' method on the query. /// public static string AutoIncludeNavigationCycle(object? cycleNavigations) => string.Format( @@ -393,7 +393,7 @@ public static string ClashingNonOwnedDerivedEntityType(object? entityType, objec entityType, derivedType); /// - /// The entity type '{entityType}' cannot be configured as owned because it has already been configured as a non-owned. If you want to override previous configuration first remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. + /// The entity type '{entityType}' cannot be configured as owned because it has already been configured as a non-owned. If the entity type should be owned remove the 'Entity<{entityType}>()' call if possible, or otherwise remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. /// public static string ClashingNonOwnedEntityType(object? entityType) => string.Format( @@ -417,7 +417,7 @@ public static string ClashingOwnedDerivedEntityType(object? entityType, object? entityType, derivedType); /// - /// The entity type '{entityType}' cannot be configured as non-owned because it has already been configured as a owned. Use the nested builder in `OwnsOne` or `OwnsMany` on the owner entity type builder to further configure this type. If you want to override previous configuration first remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. + /// The entity type '{entityType}' cannot be configured as non-owned because it has already been configured as a owned. Use the nested builder in 'OwnsOne' or 'OwnsMany' on the owner entity type builder to further configure this type. If the entity type shouldn't be owned and you are unable to remove the 'OwnsOne' or 'OwnsMany' call you can remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. /// public static string ClashingOwnedEntityType(object? entityType) => string.Format( @@ -2184,10 +2184,12 @@ public static string NullRequiredPrimitiveCollection(object? type, object? prope type, property); /// - /// The object has been removed from the model. + /// The object '{name}' has been removed from the model. /// - public static string ObjectRemovedFromModel - => GetString("ObjectRemovedFromModel"); + public static string ObjectRemovedFromModel(object? name) + => string.Format( + GetString("ObjectRemovedFromModel", nameof(name)), + name); /// /// Options extension of type '{optionsExtension}' not found. diff --git a/src/EFCore/Properties/CoreStrings.resx b/src/EFCore/Properties/CoreStrings.resx index 5c073247cd8..fe9e0b97042 100644 --- a/src/EFCore/Properties/CoreStrings.resx +++ b/src/EFCore/Properties/CoreStrings.resx @@ -157,7 +157,7 @@ The [{attribute}] attribute may only be specified on entity type properties. Remove the attribute from '{type}.{propertyName}'. - Cycle detected while auto-including navigations: {cycleNavigations}. To fix this issue, either don't configure at least one navigation in the cycle as auto included in `OnModelCreating` or call 'IgnoreAutoInclude' method on the query. + Cycle detected while auto-including navigations: {cycleNavigations}. To fix this issue, either don't configure at least one navigation in the cycle as auto included in 'OnModelCreating' or call 'IgnoreAutoInclude' method on the query. Cannot set backing field '{field}' for the indexer property '{entityType}.{property}'. Ensure no backing fields are specified for indexer properties. @@ -256,7 +256,7 @@ The entity type '{entityType}' cannot be marked as owned because the derived entity type '{derivedType}' has been configured as non-owned. Either don't configure '{derivedType}' as non-owned, or call 'HasBaseType(null)' for it in 'OnModelCreating'. See https://aka.ms/efcore-docs-owned for more information and examples. - The entity type '{entityType}' cannot be configured as owned because it has already been configured as a non-owned. If you want to override previous configuration first remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. + The entity type '{entityType}' cannot be configured as owned because it has already been configured as a non-owned. If the entity type should be owned remove the 'Entity<{entityType}>()' call if possible, or otherwise remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. 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. @@ -265,7 +265,7 @@ The entity type '{entityType}' cannot be marked as non-owned because the derived entity type '{derivedType}' has been configured as owned. Either don't configure '{derivedType}' as owned, or call 'HasBaseType(null)' for it in 'OnModelCreating'. See https://aka.ms/efcore-docs-owned for more information and examples. - The entity type '{entityType}' cannot be configured as non-owned because it has already been configured as a owned. Use the nested builder in `OwnsOne` or `OwnsMany` on the owner entity type builder to further configure this type. If you want to override previous configuration first remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. + The entity type '{entityType}' cannot be configured as non-owned because it has already been configured as a owned. Use the nested builder in 'OwnsOne' or 'OwnsMany' on the owner entity type builder to further configure this type. If the entity type shouldn't be owned and you are unable to remove the 'OwnsOne' or 'OwnsMany' call you can remove the entity type from the model by calling 'Ignore'. See https://aka.ms/efcore-docs-owned for more information and examples. The entity type '{entityType}' cannot be added to the model because its CLR type has been configured as a shared type. @@ -1256,7 +1256,7 @@ The primitive collection property '{type}.{property}' is configured as required (non-nullable) but has a null value when saving changes. Either mark the property as optional (nullable) or set a non-null value. - The object has been removed from the model. + The object '{name}' has been removed from the model. Options extension of type '{optionsExtension}' not found.