{"record":{"id":"dcfb8d53ef24b0a2","repo":"dotnet/efcore","slug":"the-object-name-has-been-removed-from-the-mode-dcfb8d","errorCode":null,"errorMessage":"The object '{name}' has been removed from the model.","messagePattern":"The object '(.+?)' has been removed from the model\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs","lineNumber":49,"sourceCode":"        bool forRowsAffected,\n        string? propertyName)\n    {\n        StoredProcedure = storedProcedure;\n        ForRowsAffected = forRowsAffected;\n        PropertyName = propertyName;\n        _builder = new InternalStoredProcedureResultColumnBuilder(this, storedProcedure.Builder.ModelBuilder);\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual InternalStoredProcedureResultColumnBuilder Builder\n    {\n        [DebuggerStepThrough]\n        get => _builder ?? throw new InvalidOperationException(CoreStrings.ObjectRemovedFromModel(Name));\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public virtual bool IsInModel\n        => _builder is not null\n            && StoredProcedure.IsInModel;\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Internal/StoredProcedureResultColumn.cs#L31-L67","documentation":"Accessing the Builder of a StoredProcedureResultColumn that was removed from the model throws, because _builder is null. The result column is no longer part of the live metadata graph.","triggerScenarios":"Holding a stale StoredProcedureResultColumn reference after it (or its procedure) was removed, then reading .Builder or invoking a builder API.","commonSituations":"Convention code caching result-column references across reconfigurations; removing a result column while another path still uses the reference; using metadata snapshots after the model was made read-only.","solutions":["Do not cache result-column metadata across model mutations; re-query from the live procedure.","Check resultColumn.IsInModel before accessing .Builder.","Re-fetch via StoredProcedure.FindResultColumn(name).","Ensure convention code runs before removal, or re-resolves references after."],"exampleFix":"// before\nvar col = proc.ResultColumns[0];\nproc.RemoveResultColumn(col.Name);\nvar b = col.Builder; // throws\n\n// after\nvar col = proc.FindResultColumn(name);\nif (col is { IsInModel: true })\n{\n    var b = col.Builder;\n}","handlingStrategy":"validation","validationCode":"if (resultColumn.IsInModel)\n{\n    var builder = resultColumn.Builder;\n}","typeGuard":"static bool IsLiveResultColumn(StoredProcedureResultColumn c)\n    => c.IsInModel;","tryCatchPattern":null,"preventionTips":["Do not retain result-column references after reconfiguring the procedure.","Re-resolve via FindResultColumn from the live procedure.","Check IsInModel before touching .Builder."],"tags":["ef-core","stored-procedure","metadata","lifecycle","internal-api"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}