diff --git a/src/EFCore/Metadata/Internal/PropertyBase.cs b/src/EFCore/Metadata/Internal/PropertyBase.cs index 4c96274ac7b..8e3577aeda8 100644 --- a/src/EFCore/Metadata/Internal/PropertyBase.cs +++ b/src/EFCore/Metadata/Internal/PropertyBase.cs @@ -148,6 +148,14 @@ public virtual void SetField([CanBeNull] FieldInfo fieldInfo, ConfigurationSourc return; } + if (PropertyInfo != null + && PropertyInfo.IsIndexerProperty() + && fieldInfo != null) + { + throw new InvalidOperationException( + CoreStrings.BackingFieldOnIndexer(fieldInfo.GetSimpleMemberName(), DeclaringType.DisplayName(), Name)); + } + if (fieldInfo != null) { IsCompatible(fieldInfo, ClrType, DeclaringType.ClrType, Name, shouldThrow: true);