dotnet/efcore · error · InvalidOperationException
Unable to find a store type mapping for column '{table}.{col
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 store type nor Dependencies.TypeMappingSource.FindMapping can resolve a store type for the column's CLR type and facets. EF first tries to reuse the model column's StoreType, then falls back to the TypeMappingSource; if both return null it cannot emit a column type and throws InvalidOperationException.
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 dbf9771522)
Solutions
- Register a type mapping or conversion for the CLR type (e.g. modelBuilder.Entity<T>().Property(x => x.MyEnum).HasConversion<int>() or .HasColumnType("jsonb")).
- Install the missing provider plugin package that maps the type (e.g. NodaTime, NetTopologySuite for SQL Server/PostgreSQL).
- Explicitly set operation.ColumnType (and the [Column(TypeName=...)] / HasColumnType) so GetColumnType short-circuits before reaching the mapping source.
- If the CLR type is genuinely unsupported, change the property to a supported type or store it as a converted primitive (string/JSON).
Example fix
// before - custom enum type has no mapping
public class Order { public OrderStatus Status { get; set; } } // OrderStatus is a custom enum
// after - explicit conversion + column type
modelBuilder.Entity<Order>()
.Property(o => o.Status)
.HasConversion<int>()
.HasColumnType("int"); Defensive patterns
Strategy: validation
Validate before calling
foreach (var et in dbContext.Model.GetEntityTypes())
foreach (var p in et.GetProperties())
{
var storeType = p.GetColumnType();
if (string.IsNullOrEmpty(storeType) && p.ClrType.IsEnum && !p.GetJsonValueConverter()?.GetType().IsValueType)
Console.WriteLine($"{et}.{p.Name} ({p.ClrType}) has no store type mapping; add HasConversion/HasColumnType.");
} Prevention
- Register HasConversion for custom enums/types in OnModelCreating.
- Install provider plugins (NodaTime, NetTopologySuite) before using their types.
- Set HasColumnType explicitly for any non-standard CLR type.
When it happens
Trigger: A column operation whose ClrType is a type the provider's type mapper does not know about (e.g. a custom struct/enum or an object/unknown type); a migration column where operation.ClrType is null (reported as 'unknown'); using a value type with no registered RelationalTypeMapping.
Common situations: Adding a property of an unmapped CLR type (e.g. a custom enum without HasConversion, a third-party type like NodaTime without the provider plugin); stripping ClrType in a hand-edited migration; provider plugin missing (e.g. NodaTime, NetTopologySuite) so its types are unmapped; a column operation built programmatically without setting ColumnType.
Related errors
- The provider '{provider}' is not a Relational provider and t
- The current migration SQL generator '{sqlGeneratorType}' is
- No DbContext named '{name}' was found.
- Unable to find provider assembly '{assemblyName}'. Ensure th
- Unable to find expected assembly attribute [DesignTimeProvid
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/9912354da4199ae2.
Report an issue: GitHub.