dotnet/efcore · error · InvalidOperationException
The entity type '{entityType}' was configured to use '{sproc
Error message
The entity type '{entityType}' was configured to use '{sproc}', but the store name was not specified. Configure the stored procedure name explicitly. What it means
Thrown when StoreObjectIdentifier.Create cannot determine a name for a stored procedure, i.e. no store name was specified and none can be derived. Each stored procedure mapping requires an explicit name (or a default table name to derive from). The validator fails fast inside ValidateStoredProcedureName when sprocId is null.
Source
Thrown at src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs:519
sprocCount++;
}
if (sprocCount > 0
// TODO: Support this with #28703
//&& sprocCount < 3
&& entityType.GetTableName() == null)
{
throw new InvalidOperationException(RelationalStrings.StoredProcedureUnmapped(entityType.DisplayName()));
}
static void ValidateStoredProcedureName(
StoreObjectType storedProcedureType,
IEntityType entityType)
{
var sprocId = StoreObjectIdentifier.Create(entityType, storedProcedureType);
if (sprocId == null)
{
throw new InvalidOperationException(
RelationalStrings.StoredProcedureNoName(
entityType.DisplayName(), storedProcedureType));
}
}
}
/// <summary>
/// Validates a single stored procedure and all entity types mapped to it.
/// </summary>
/// <param name="mappedTypes">The entity types mapped to the stored procedure.</param>
/// <param name="storedProcedure">The stored procedure identifier.</param>
/// <param name="logger">The logger to use.</param>
protected virtual void ValidateStoredProcedure(
IReadOnlyList<IEntityType> mappedTypes,
in StoreObjectIdentifier storedProcedure,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
=> ValidateStoredProcedureCompatibility(mappedTypes, storedProcedure, logger);
View on GitHub (pinned to dbf9771522)
Solutions
- Pass an explicit name: .InsertStoredProcedure("sp_InsertBlog").
- Or set a table name via ToTable so the sproc name can be derived by convention.
- Provide names for all three (insert/update/delete) sproc configurations.
Example fix
// before
modelBuilder.Entity<Blog>()
.ToTable((string)null)
.InsertStoredProcedure();
// after
modelBuilder.Entity<Blog>()
.InsertStoredProcedure("sp_InsertBlog"); Defensive patterns
Strategy: validation
Validate before calling
foreach (var et in modelBuilder.Model.GetEntityTypes())
{
foreach (var t in new[] { StoreObjectType.InsertStoredProcedure, StoreObjectType.UpdateStoredProcedure, StoreObjectType.DeleteStoredProcedure })
{
var sproc = t switch { StoreObjectType.InsertStoredProcedure => et.GetInsertStoredProcedure(), StoreObjectType.UpdateStoredProcedure => et.GetUpdateStoredProcedure(), _ => et.GetDeleteStoredProcedure() };
if (sproc != null && StoreObjectIdentifier.Create(et, t) == null)
throw new InvalidOperationException($"{et.DisplayName()} {t} has no store name");
}
} Try / catch
try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains("store name was not specified")) { /* pass explicit sproc names */ } Prevention
- Always pass an explicit name to InsertStoredProcedure/UpdateStoredProcedure/DeleteStoredProcedure.
- Do not null out the table name when relying on sproc-name convention.
When it happens
Trigger: Calling .InsertStoredProcedure() (parameterless) on an entity that has no table name set; configuring an UpdateStoredProcedure without a name and with no ToTable default.
Common situations: Relying on convention naming that does not apply; forgetting the name argument after switching to name-required sproc APIs.
Related errors
- The entity type '{entityType}' was configured to use some st
- The keyless entity type '{entityType}' was configured to use
- The property '{entityType}.{property}' is mapped to an outpu
- The property '{entityType}.{property}' is mapped to a result
- The entity type '{entityType}' is mapped to the stored proce
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/16eae5e3c083182f.
Report an issue: GitHub.