{"record":{"id":"94cd33073e187a4b","repo":"dotnet/orleans","slug":"field-fieldname-not-found-in-data-record","errorCode":null,"errorMessage":"Field '{fieldName}' not found in data record.","messagePattern":"Field '(.+?)' not found in data record\\.","errorType":"exception","errorClass":"DataException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/DbExtensions.cs","lineNumber":134,"sourceCode":"        /// Returns a value if it is not <see cref=\"System.DBNull\"/>, <em>default(TValue)</em> otherwise.\n        /// </summary>\n        /// <typeparam name=\"TValue\">The type of the value to request.</typeparam>\n        /// <param name=\"record\">The record from which to retrieve the value.</param>\n        /// <param name=\"fieldName\">The name of the field to retrieve.</param>\n        /// <param name=\"default\">The default value if value in position is <see cref=\"System.DBNull\"/>.</param>\n        /// <returns>Either the given value or the default for the requested type.</returns>\n        /// <remarks>This function throws if the given <see paramref=\"fieldName\"/> does not exist.</remarks>\n        public static TValue? GetValueOrDefault<TValue>(this IDataRecord record, string fieldName, TValue? @default = default)\n        {\n\n            try\n            {\n                var ordinal = record.GetOrdinal(fieldName);\n                return record.IsDBNull(ordinal) ? @default : (TValue)record.GetValue(ordinal);\n            }\n            catch (IndexOutOfRangeException e)\n            {\n                throw new DataException($\"Field '{fieldName}' not found in data record.\", e);\n            }\n        }\n        /// <summary>\n        /// Returns a value if it is not <see cref=\"System.DBNull\"/>, <em>default</em>  otherwise.\n        /// </summary>\n        /// <param name=\"record\">The record from which to retrieve the value.</param>\n        /// <param name=\"fieldName\">The name of the field to retrieve.</param>\n        /// <param name=\"default\">The default value if value in position is <see cref=\"System.DBNull\"/>.</param>\n        /// <returns>Either the given value or the default for <see cref=\"System.DateTime\"/>?.</returns>\n        /// <exception cref=\"DataException\"/>\n        /// <remarks>An explicit function like this is needed in cases where to connector infers a type that is undesirable.\n        /// An example here is Npgsql.NodaTime, which makes Npgsql return Noda type and consequently Orleans is not able to\n        /// use it since it expects .NET <see cref=\"System.DateTime\"/>. This function throws if the given <see paramref=\"fieldName\"/> does not exist.</remarks>\n        public static DateTime? GetDateTimeValueOrDefault(this IDataRecord record, string fieldName, DateTime? @default = default)\n        {\n            try\n            {\n                var ordinal = record.GetOrdinal(fieldName);","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/DbExtensions.cs#L116-L152","documentation":"Thrown by the GetValueOrDefault<TValue> extension on IDataRecord when record.GetOrdinal(fieldName) raises IndexOutOfRangeException, which is re-wrapped as a DataException. It means the result set returned by the database does not contain a column with the requested name. Orleans wraps the original exception as InnerException so the caller can still inspect it.","triggerScenarios":"Calling record.GetValueOrDefault<TValue>(\"SomeColumn\") where 'SomeColumn' is not present in the current IDataRecord's schema. This is invoked internally by Orleans converters (e.g. when reading membership, reminder, or stream rows) and by custom query selectors.","commonSituations":"The Orleans database schema is out of date (older scripts applied) so a column was renamed or removed; a custom OrleansQuery entry selects fewer columns than the converter expects; the wrong query key was loaded for the storage feature in use.","solutions":["Re-run the Orleans database setup/migration scripts for the correct version so the schema and OrleansQuery rows match.","If using custom queries, ensure each SELECT includes every column the Orleans converter references by name.","Verify you are using scripts matching your Orleans package version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var v = record.GetValueOrDefault<string>(\"ColumnName\"); }\ncatch (DataException ex) { /* log schema mismatch, surface which column is missing */ throw; }","preventionTips":["Keep the Orleans schema scripts in sync with the installed Orleans package version.","Never hand-edit OrleansQuery rows to drop columns the converters expect.","Run a schema-version check at deployment time."],"tags":["adonet","data-record","schema","database","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}