dotnet/orleans · error · DataException
Field '{fieldName}' not found in data record.
Error message
Field '{fieldName}' not found in data record. What it means
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.
Source
Thrown at src/AdoNet/Shared/Storage/DbExtensions.cs:134
/// Returns a value if it is not <see cref="System.DBNull"/>, <em>default(TValue)</em> otherwise.
/// </summary>
/// <typeparam name="TValue">The type of the value to request.</typeparam>
/// <param name="record">The record from which to retrieve the value.</param>
/// <param name="fieldName">The name of the field to retrieve.</param>
/// <param name="default">The default value if value in position is <see cref="System.DBNull"/>.</param>
/// <returns>Either the given value or the default for the requested type.</returns>
/// <remarks>This function throws if the given <see paramref="fieldName"/> does not exist.</remarks>
public static TValue? GetValueOrDefault<TValue>(this IDataRecord record, string fieldName, TValue? @default = default)
{
try
{
var ordinal = record.GetOrdinal(fieldName);
return record.IsDBNull(ordinal) ? @default : (TValue)record.GetValue(ordinal);
}
catch (IndexOutOfRangeException e)
{
throw new DataException($"Field '{fieldName}' not found in data record.", e);
}
}
/// <summary>
/// Returns a value if it is not <see cref="System.DBNull"/>, <em>default</em> otherwise.
/// </summary>
/// <param name="record">The record from which to retrieve the value.</param>
/// <param name="fieldName">The name of the field to retrieve.</param>
/// <param name="default">The default value if value in position is <see cref="System.DBNull"/>.</param>
/// <returns>Either the given value or the default for <see cref="System.DateTime"/>?.</returns>
/// <exception cref="DataException"/>
/// <remarks>An explicit function like this is needed in cases where to connector infers a type that is undesirable.
/// An example here is Npgsql.NodaTime, which makes Npgsql return Noda type and consequently Orleans is not able to
/// use it since it expects .NET <see cref="System.DateTime"/>. This function throws if the given <see paramref="fieldName"/> does not exist.</remarks>
public static DateTime? GetDateTimeValueOrDefault(this IDataRecord record, string fieldName, DateTime? @default = default)
{
try
{
var ordinal = record.GetOrdinal(fieldName);View on GitHub (pinned to fca799fa70)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try { var v = record.GetValueOrDefault<string>("ColumnName"); }
catch (DataException ex) { /* log schema mismatch, surface which column is missing */ throw; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Not all required queries found. Missing are: {string.Join(",
- Expected a single column
- Database provider factory with '{invariantName}' invariant n
- Value cannot be null. (Parameter 'invariantName')
- Value cannot be null. (Parameter 'connectionString')
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/94cd33073e187a4b.
Report an issue: GitHub.