dotnet/efcore · error · InvalidOperationException
The property '{1_entityType}.{0_property}' could not be foun
Error message
The property '{1_entityType}.{0_property}' could not be found. Ensure that the property exists and has been included in the model. What it means
Thrown by StoredProcedureBuilder.CreatePropertyBuilder(string) at StoredProcedureBuilder.cs:218-220 when the property name is not found on the entity type or any of its derived types. FindProperty is checked on the entity itself, then GetDerivedTypes().SelectMany(GetDeclaredProperties) is searched; if both fail, the exception is thrown.
Source
Thrown at src/EFCore.Relational/Metadata/Builders/StoredProcedureBuilder.cs:220
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
protected virtual PropertyBuilder CreatePropertyBuilder(string propertyName)
{
var entityType = EntityTypeBuilder.Metadata;
var property = entityType.FindProperty(propertyName);
property ??= entityType.GetDerivedTypes().SelectMany(et => et.GetDeclaredProperties())
.FirstOrDefault(p => p.Name == propertyName);
if (property == null)
{
throw new InvalidOperationException(CoreStrings.PropertyNotFound(propertyName, entityType.DisplayName()));
}
#pragma warning disable EF1001 // Internal EF Core API usage.
return new ModelBuilder(entityType.Model)
#pragma warning restore EF1001 // Internal EF Core API usage.
.Entity(property.DeclaringType.Name)
.Property(property.ClrType, propertyName);
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
protected virtual PropertyBuilder CreatePropertyBuilder<TDerivedEntity, TProperty>(
Expression<Func<TDerivedEntity, TProperty>> propertyExpression)View on GitHub (pinned to dbf9771522)
Solutions
- Verify the property name exactly matches a declared property (including derived types if using inheritance).
- Declare a shadow property first with .Property<T>("Name") if it's not a CLR property.
- Use the strongly-typed lambda overload to get compile-time safety.
Example fix
// before: property name doesn't exist
modelBuilder.Entity<User>()
.UpdateUsingStoredProcedure(sp => sp.HasParameter("EmailAddress")); // property is 'Email'
// after
modelBuilder.Entity<User>()
.UpdateUsingStoredProcedure(sp => sp.HasParameter("Email")); Defensive patterns
Strategy: type-guard
Validate before calling
var et = entityTypeBuilder.Metadata;
var prop = et.FindProperty(propertyName)
?? et.GetDerivedTypes().SelectMany(d => d.GetDeclaredProperties()).FirstOrDefault(p => p.Name == propertyName);
if (prop == null) throw new ArgumentException($"Property '{propertyName}' not found.");
// safe to proceed with stored procedure mapping Type guard
// Prefer strongly-typed lambda overloads to get compile-time checking sp.HasParameter<TProperty>(e => e.MyProperty);
Prevention
- Use lambda-based stored procedure configuration overloads for compile-time property validation.
- Validate property names with FindProperty before string-based configuration.
- Run model validation tests that exercise all stored procedure mappings.
When it happens
Trigger: Calling stored procedure mapping methods (HasParameter, HasResultColumn, HasOriginalValueParameter, etc.) with a string property name that doesn't exist on the entity type or its inheritance descendants.
Common situations: Typo in the property name. Referencing a property from a different entity. Property renamed during refactoring but the stored procedure string wasn't updated. Shadow property not declared before use in stored procedure mapping.
Related errors
- The property '{1_entityType}.{0_property}' could not be foun
- The stored procedure '{sproc}' cannot be configured to retur
- Invalid number of index sort order values: {numValues} value
- IsDescending and AllDescending cannot both be specified on t
- The number argument cannot be a negative number.
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/b8c85d244ab01494.
Report an issue: GitHub.