dotnet/efcore · error · InvalidOperationException
The property ' . ' could not be found. Ensure that the…
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
The internal OwnedNavigationStoredProcedureBuilder.CreatePropertyBuilder looks up a property by name on the owned entity type (entityType.FindProperty). If no property with that name exists, it throws CoreStrings.PropertyNotFound. This fires when a stored-procedure mapping for an owned navigation references a property name that is not part of the owned entity's model.
Solutions
- Use the exact property name as declared on the owned entity type.
- Prefer the strongly-typed lambda overload (CreatePropertyBuilder<T,TProperty>(propertyExpression)) which is compile-checked and avoids string typos.
- Confirm the property is actually included in the model (not ignored via .Ignore).
Example fix
// before
modelBuilder.Entity<Customer>()
.OwnsOne(c => c.Address, a =>
{
a.HasData(...);
a.UpdateStoredProcedure("UpsertAddress", sp => sp.HasParameter("Zip")); // property is 'ZipCode' -> [453]
});
// after
modelBuilder.Entity<Customer>()
.OwnsOne(c => c.Address, a =>
{
a.UpdateStoredProcedure("UpsertAddress", sp => sp.HasParameter(a => a.ZipCode));
}); Defensive patterns
Strategy: type-guard
Validate before calling
// Verify the property exists on the owned entity before configuring the sproc.
var owned = modelBuilder.Entity<Customer>().OwnsOne(c => c.Address).OwnedEntityType;
if (owned.FindProperty("ZipCode") is null)
throw new ArgumentException("Property 'ZipCode' not found on owned type Address."); Type guard
static bool OwnedTypeHasProperty(IEntityType owned, string name)
=> owned.FindProperty(name) is not null; Prevention
- Prefer lambda-based HasParameter/HasResultColumn overloads for compile-time safety.
- Update sproc string mappings whenever a property is renamed.
- Build the model in a unit test to surface typos at test time.
When it happens
Trigger: Configuring an owned navigation's stored procedure (e.g. .HasParameter("WrongName") or a result/column binding) and passing a string property name that does not exist on the owned entity type; renamed or removed properties; typos.
Common situations: Renaming a property without updating sproc mapping strings; refactor of owned type; copy-paste of sproc config between entities.
Related errors
- Table name must be specified to configure a table-specific…
- The property ' . ' could not be found. Ensure that the…
- Table name must be specified to configure a table-specific…
- A rows affected parameter, result column or return value…
- Both ' ' and ' ' are explicitly mapped to the stored…
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/1ca4f741a9e033ad.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Metadata/Builders/OwnedNavigationStoredProcedureBuilder.cs:141
{
var parameterBuilder = Builder.HasRowsAffectedParameter(ConfigurationSource.Explicit)!;
buildAction(new StoredProcedureParameterBuilder(parameterBuilder, null));
return this;
}
/// <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 = OwnedNavigationBuilder.OwnedEntityType;
var property = entityType.FindProperty(propertyName);
return property == null
? throw new InvalidOperationException(CoreStrings.PropertyNotFound(propertyName, entityType.DisplayName()))
: OwnedNavigationBuilder.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<TDependentEntity, TProperty>(
Expression<Func<TDependentEntity, TProperty>> propertyExpression)
{
var memberInfo = propertyExpression.GetMemberAccess();
return OwnedNavigationBuilder.Property(memberInfo.GetMemberType(), memberInfo.Name);
}
/// <summary>View on GitHub (pinned to 3a2006ef56)