{"record":{"id":"16eae5e3c083182f","repo":"dotnet/efcore","slug":"the-entity-type-entitytype-was-configured-to-u-16eae5","errorCode":null,"errorMessage":"The entity type '{entityType}' was configured to use '{sproc}', but the store name was not specified. Configure the stored procedure name explicitly.","messagePattern":"The entity type '(.+?)' was configured to use '(.+?)', but the store name was not specified\\. Configure the stored procedure name explicitly\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":519,"sourceCode":"            sprocCount++;\n        }\n\n        if (sprocCount > 0\n            // TODO: Support this with #28703\n            //&& sprocCount < 3\n            && entityType.GetTableName() == null)\n        {\n            throw new InvalidOperationException(RelationalStrings.StoredProcedureUnmapped(entityType.DisplayName()));\n        }\n\n        static void ValidateStoredProcedureName(\n            StoreObjectType storedProcedureType,\n            IEntityType entityType)\n        {\n            var sprocId = StoreObjectIdentifier.Create(entityType, storedProcedureType);\n            if (sprocId == null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.StoredProcedureNoName(\n                        entityType.DisplayName(), storedProcedureType));\n            }\n        }\n    }\n\n    /// <summary>\n    ///     Validates a single stored procedure and all entity types mapped to it.\n    /// </summary>\n    /// <param name=\"mappedTypes\">The entity types mapped to the stored procedure.</param>\n    /// <param name=\"storedProcedure\">The stored procedure identifier.</param>\n    /// <param name=\"logger\">The logger to use.</param>\n    protected virtual void ValidateStoredProcedure(\n        IReadOnlyList<IEntityType> mappedTypes,\n        in StoreObjectIdentifier storedProcedure,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n        => ValidateStoredProcedureCompatibility(mappedTypes, storedProcedure, logger);\n","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L501-L537","documentation":"Thrown inside the local ValidateStoredProcedureName function when StoreObjectIdentifier.Create(entityType, storedProcedureType) returns null — meaning the stored procedure's store name cannot be derived (RelationalModelValidator.cs:516-522). This happens when the sproc is configured but no name/schema was supplied and no convention could fill it.","triggerScenarios":"Calling .InsertUsingStoredProcedure(sp => { }) with an empty/null name or relying on convention-based name resolution when conventions are disabled or the entity name is unset. Also when a custom IModelCustomizer strips the name annotation.","commonSituations":"Using the lambda overload that omits the explicit name and the default-name convention produced an empty string; setting HasName(null); scaffolding generated incomplete sproc config; running with model caching where the name was conditionally set and the cache key didn't differentiate.","solutions":["Supply the stored-procedure name explicitly: .InsertUsingStoredProcedure(\"dbo.CustomerInsert\", sp => { ... }) (and likewise for Update/Delete).","If using the overload that takes a builder without a name, add .HasName(\"YourSproc\") inside the configuration.","Ensure conventions that compute default names are enabled (haven't been removed via modelBuilder.Model.RemoveConvention(...)).","Verify the entity itself has a name (entityType.DisplayName()) so the convention has something to base the sproc name on."],"exampleFix":"// before — name omitted, convention yields nothing\nmodelBuilder.Entity<Customer>()\n    .InsertUsingStoredProcedure(sp =>\n    {\n        sp.HasParameter(c => c.Id);\n        sp.HasResultColumn(c => c.Id);\n    });\n\n// after — explicit store name and schema\nmodelBuilder.Entity<Customer>()\n    .InsertUsingStoredProcedure(\"dbo.CustomerInsert\", sp =>\n    {\n        sp.HasParameter(c => c.Id);\n        sp.HasResultColumn(c => c.Id);\n    });","handlingStrategy":"validation","validationCode":"foreach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    foreach (StoreObjectType kind in new[] { StoreObjectType.InsertStoredProcedure, StoreObjectType.UpdateStoredProcedure, StoreObjectType.DeleteStoredProcedure })\n    {\n        if (StoreObjectIdentifier.Create(et, kind) is null\n            && (kind == StoreObjectType.InsertStoredProcedure ? et.GetInsertStoredProcedure()\n              : kind == StoreObjectType.UpdateStoredProcedure ? et.GetUpdateStoredProcedure()\n              : et.GetDeleteStoredProcedure()) is not null)\n        {\n            throw new InvalidOperationException($\"Entity '{et.Name}' has a {kind} with no store name; call .HasName(...).\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try { _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"store name was not specified\"))\n{\n    logger.LogError(\"Supply an explicit sproc name. {Msg}\", ex.Message);\n    throw;\n}","preventionTips":["Always pass an explicit name string to *UsingStoredProcedure(...).","Avoid disabling naming conventions that compute default sproc names.","In IEntityTypeConfiguration, set .HasName(...) inside every sproc builder."],"tags":["efcore","relational","stored-procedure","naming","entity-mapping","model-validation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}