dotnet/efcore · error · InvalidOperationException
Unable to find a store type mapping for column
Error message
Unable to find a store type mapping for column '{table}.{column}' with CLR type '{clrType}'. What it means
Thrown by MigrationsSqlGenerator.GetColumnType when neither the relational model's column metadata nor the configured TypeMappingSource can resolve a store type for the column's CLR type. The relational provider cannot emit DDL for a type it cannot map.
Solutions
- Register a value converter on the property: builder.Property(x => x.Foo).HasConversion(...).
- Install the provider extension package for the unsupported type (e.g. EFCore.NodaTime, EFCore.NetTopologySuite).
- Change the CLR type to one the provider maps natively, or specify the store type explicitly via .HasColumnType("...").
- Provide columnType on the AddColumnOperation so the generator bypasses the FindMapping call.
Example fix
// before
modelBuilder.Entity<Order>()
.Property(o => o.Flags); // Flags is a custom struct with no mapping
// after
modelBuilder.Entity<Order>()
.Property(o => o.Flags)
.HasConversion(v => v.ToString(), v => MyFlags.Parse(v));
// or
modelBuilder.Entity<Order>()
.Property(o => o.Flags)
.HasColumnType("nvarchar(max)"); Defensive patterns
Strategy: validation
Validate before calling
static void EnsureTypeMappable(IRelationalTypeMappingSource source, Type clrType)
{
if (source.FindMapping(clrType) is null)
throw new InvalidOperationException($"No store type mapping for CLR type {clrType}. Register a value converter or install the provider extension.");
} Type guard
static bool HasMapping(IRelationalTypeMappingSource source, Type clrType)
=> source.FindMapping(clrType) is not null; Prevention
- Install provider extension packages for non-native types (NodaTime, NetTopologySuite, enums).
- Register HasConversion for unsupported CLR types.
- Specify .HasColumnType on properties whose CLR type is exotic.
When it happens
Trigger: AddColumn/AlterColumn in a migration whose ClrType has no registered mapping (e.g. a custom struct/enum without a value converter, or third-party type). Fires when Dependencies.TypeMappingSource.FindMapping(...) returns null.
Common situations: Adding a property whose CLR type is not natively supported (e.g. ulong on some providers, custom enum, decimal without scale, NodaTime types without the plugin). Forgetting to register HasConversion. Missing provider-specific package (e.g. NodaTime, NetTopologySuite).
Related errors
- A seed entity for entity type
- Model building is not supported when publishing with…
- Model building is not supported when publishing with…
- values were provided in CreateIndexOperations.IsDescending…
- Relational-specific methods can only be used when the…
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/9912354da4199ae2.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs:1451
var storeType = Dependencies.TypeMappingSource.FindMapping(
operation.ClrType,
null,
keyOrIndex,
operation.IsUnicode,
operation.MaxLength,
operation.IsRowVersion,
operation.IsFixedLength,
operation.Precision,
operation.Scale)
?.StoreType;
if (storeType != null)
{
return storeType;
}
var fullTableName = schema != null ? $"{schema}.{tableName}" : tableName;
throw new InvalidOperationException(
RelationalStrings.UnsupportedTypeForColumn(fullTableName, name, operation.ClrType?.Name ?? "unknown"));
}
/// <summary>
/// Generates a SQL fragment for the default constraint of a column.
/// </summary>
/// <param name="defaultValue">The default value for the column.</param>
/// <param name="defaultValueSql">The SQL expression to use for the column's default constraint.</param>
/// <param name="columnType">Store/database type of the column.</param>
/// <param name="builder">The command builder to use to add the SQL fragment.</param>
protected virtual void DefaultValue(
object? defaultValue,
string? defaultValueSql,
string? columnType,
MigrationCommandListBuilder builder)
{
if (defaultValueSql != null)
{View on GitHub (pinned to 3a2006ef56)