Entity Framework Core: System.InvalidOperationException: The property X is of type Y which is not supported by current database provider. Either change the property CLR type or ignore the property using the ‘[NotMapped]’ attribute or by using ‘EntityTypeBuilder.Ignore’ in ‘OnModelCreating’.

Maarten Merken
Agilix
Published in
2 min readSep 23, 2018

This exception happens when you try to map a type that is not supported by EF Core. Either change the type of the property or write a custom ValueConverter for the type.

Please keep in mind that valueconverters are an EF Core 2.1 feature

If you have written a custom value converter and the issue still persists, you probably still have a type-problem in your ValueConverter.

The HasConversion extension method takes two parameters

  • The conversion from the property to the column
  • The conversion from the column to the property

This may appear to be correct, but the SqlDateTime type is not a supported type of the SqlServer adapter for EF Core. The correct type is DateTime.

If we change the conversion to convert from a DateTime, then the model gets build correctly.

For sake of exhaustiveness, here’s the MyEntity class and its custom property.

I’m currently writing a post on how to map a column into an expanded property, stay tuned!

--

--