dotnet/efcore · error · InvalidOperationException

No property named '{property}' found on the entity type '{en

Error message

No property named '{property}' found on the entity type '{entityType}' corresponding to the result column on the stored procedure '{sproc}'.

What it means

Thrown when a stored procedure result column references a property name that is not found in the valid property set for the entity and mapping strategy. The validator looks up resultColumn.PropertyName in the properties dictionary (which varies by TPH/TPT/TPC) and rejects an unknown name. Result columns must correspond to actual properties.

Source

Thrown at src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs:659

        if (mappingStrategy == RelationalAnnotationNames.TptMappingStrategy
            && storeObjectIdentifier.StoreObjectType == StoreObjectType.InsertStoredProcedure
            && entityType.BaseType?.GetInsertStoredProcedure() != null)
        {
            foreach (var property in primaryKey.Properties)
            {
                storeGeneratedProperties.Remove(property.Name);
            }
        }

        var resultColumnNames = new HashSet<string>();
        foreach (var resultColumn in sproc.ResultColumns)
        {
            IProperty? property = null!;
            if (resultColumn.PropertyName != null
                && !properties.TryGetValue(resultColumn.PropertyName, out property))
            {
                throw new InvalidOperationException(
                    RelationalStrings.StoredProcedureResultColumnNotFound(
                        resultColumn.PropertyName, entityType.DisplayName(), storeObjectIdentifier.DisplayName()));
            }

            if (!resultColumnNames.Add(resultColumn.Name))
            {
                throw new InvalidOperationException(
                    RelationalStrings.StoredProcedureDuplicateResultColumnName(
                        resultColumn.Name, storeObjectIdentifier.DisplayName()));
            }

            if (resultColumn.PropertyName == null)
            {
                continue;
            }

            switch (storeObjectIdentifier.StoreObjectType)
            {

View on GitHub (pinned to dbf9771522)

Solutions

  1. Verify the property name exactly matches an existing property on the entity.
  2. Check the mapping strategy; ensure the property is in scope (e.g. derived properties need TPH).
  3. Remove the result column if it references a non-existent property.

Example fix

// before
.InsertStoredProcedure("sp_InsertBlog", sp =>
{
    sp.HasResultColumn("CreateDate"); // property is actually named CreatedOn
});

// after
sp.HasResultColumn("CreatedOn");
Defensive patterns

Strategy: validation

Validate before calling

foreach (var et in modelBuilder.Model.GetEntityTypes())
{
    var names = et.GetProperties().Select(p => p.Name).ToHashSet();
    foreach (var t in new[] { StoreObjectType.InsertStoredProcedure, StoreObjectType.UpdateStoredProcedure })
    {
        var sproc = t == StoreObjectType.InsertStoredProcedure ? et.GetInsertStoredProcedure() : et.GetUpdateStoredProcedure();
        if (sproc == null) continue;
        foreach (var rc in sproc.ResultColumns)
            if (rc.PropertyName != null && !names.Contains(rc.PropertyName))
                throw new InvalidOperationException($"Result column {rc.PropertyName} not a property of {et.DisplayName()}");
    }
}

Try / catch

try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains("No property named")) { /* fix the result column property name */ }

Prevention

When it happens

Trigger: Calling .HasResultColumn("TypoName"); referencing a property that was renamed or removed; referencing a derived property under a strategy that excludes it.

Common situations: Renaming a property without updating the sproc config; strategy changes (e.g. TPH->TPT) that alter which properties are in scope; stale sproc mappings after model refactors.

Related errors


AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06). Data as JSON: /api/errors/c2f4cd092f9c1dd5. Report an issue: GitHub.