0
votes

Yesterday I managed to call the SQL EOMONTH function from EF Core thanks to this answer, but now I need to call it using the new DateOnly type:

class MyContext : DbContext
{
    [DbFunction(IsBuiltIn = true)]
    public static DateTime EOMONTH(DateOnly startDate)
        => throw new InvalidOperationException(
            "Don't call EOMONTH directly. It must to be translated to SQL " +
            "inside of a LINQ query.");
}

I've already implemented the support for using as a column in the entities:

protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{
    builder.Properties<DateOnly>()
        .HaveConversion<DateOnlyConverter, DateOnlyComparer>()
        .HaveColumnType("date");
}

but the above definition of EOMONTH throws the following exception when starting to run the API:

enter image description here

How can I get it to accept this custom type as a parameter for a DbFunction?