I upgraded from framework to .NetCore with XAF 21.2.5
Now if I try to use the following ListViewFilter
[ListViewFilter("Today",
"[Created] >= LocalDateTimeToday()",
"Today", true, Index = 0)]
on my business object which has properties
public DateTime Created { get; set; }
I get an error
Microsoft.Data.SqlClient.SqlException
HResult=0x80131904
Message=Conversion failed when converting date and/or time from character string.
Source=Core Microsoft SqlClient Data Provider
StackTrace:
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
The docs indicate this should work
[Update]
After reading this question I started experimenting with
modelBuilder.Entity<MyEntity>().Property(x => x.Created).HasColumnType("datetime");
I am searching for the nullable one so as to map all the datetime properties.
The solution turned out to be to add the following to the OnModelCreating
modelBuilder.Entity<MyEntity>().Property(x => x.Created).HasColumnType("datetime");
And to carefully check each declared property in the entity to ensure that I had whether or not it was nullable set correctly
I had an int? incorrectly declared as an int