I have a database table with a column of type date, null. The corresponding entity class maps this column to a property with the DateOnly? type. There are no custom converters defined the application.
However, attempting to map this specific column from the table to this particular property results in InvalidCastException: 'Unable to cast object of type 'System.DateTime' to type 'System.DateOnly'.'.
This error persists even when overriding ConfigureConventions() in the DbContext with
configBuilder.Properties().HaveColumnType("date");
This is baffling since EntityFramework Core has supported DateOnly since version 8.0.
Did I overlook a configuration setting related to mapping the SQL Server date column type to DateOnly in a database-first context?