{"record":{"id":"c4207d6f083ff6d6","repo":"dotnet/efcore","slug":"the-entity-type-entitytype-was-configured-to-u","errorCode":null,"errorMessage":"The entity type '{entityType}' was configured to use some stored procedures and is not mapped to any table. An entity type that isn't mapped to a table must be mapped to insert, update and delete stored procedures.","messagePattern":"The entity type '(.+?)' was configured to use some stored procedures and is not mapped to any table\\. An entity type that isn't mapped to a table must be mapped to insert, update and delete stored procedures\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":509,"sourceCode":"            ValidateStoredProcedureName(StoreObjectType.InsertStoredProcedure, entityType);\n            ValidateSproc(insertStoredProcedure, mappingStrategy, logger);\n            sprocCount++;\n        }\n\n        var updateStoredProcedure = entityType.GetUpdateStoredProcedure();\n        if (updateStoredProcedure != null)\n        {\n            ValidateStoredProcedureName(StoreObjectType.UpdateStoredProcedure, entityType);\n            ValidateSproc(updateStoredProcedure, mappingStrategy, logger);\n            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.","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L491-L527","documentation":"Thrown when an entity type has some stored procedures configured but is not mapped to any table (GetTableName() == null). Entity types that skip table mapping must be fully covered by insert, update AND delete stored procedures; a partial sproc set with no table is invalid. The validator counts configured sprocs and rejects a non-zero count with a null table name.","triggerScenarios":"Calling .InsertStoredProcedure(...) on an entity with ToView/HasNoKey/no ToTable, without also adding Update and Delete sprocs; migrating an entity off tables onto sprocs but only finishing the insert.","commonSituations":"Switching a keyless or view-backed entity to sprocs piecemeal; partial config left over from a refactor.","solutions":["Add all three stored procedures: InsertStoredProcedure, UpdateStoredProcedure, and DeleteStoredProcedure.","Or restore a table mapping (ToTable/ToView) so the entity is not unmapped."],"exampleFix":"// before\nmodelBuilder.Entity<Blog>()\n    .ToView(null)\n    .InsertStoredProcedure(\"sp_InsertBlog\");\n\n// after\nmodelBuilder.Entity<Blog>()\n    .InsertStoredProcedure(\"sp_InsertBlog\")\n    .UpdateStoredProcedure(\"sp_UpdateBlog\")\n    .DeleteStoredProcedure(\"sp_DeleteBlog\");","handlingStrategy":"validation","validationCode":"foreach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    var hasSproc = et.GetInsertStoredProcedure() != null || et.GetUpdateStoredProcedure() != null || et.GetDeleteStoredProcedure() != null;\n    if (hasSproc && et.GetTableName() == null)\n    {\n        var count = (et.GetInsertStoredProcedure() != null ? 1 : 0) + (et.GetUpdateStoredProcedure() != null ? 1 : 0) + (et.GetDeleteStoredProcedure() != null ? 1 : 0);\n        if (count < 3) throw new InvalidOperationException($\"{et.DisplayName()} has partial sprocs and no table\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { _ = ctx.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"not mapped to any table\")) { /* add the missing update/delete sprocs or a table mapping */ }","preventionTips":["When moving an entity off tables, configure all three sprocs together.","Add a model test asserting every sproc-bearing entity is fully mapped."],"tags":["ef-core","stored-procedures","mapping","model-validation","configuration"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}