I'm starting to use EntityFramework 6 with Oracle (client 12.x). I have severals tables with DATE columns and TIMESTAMP columns.
All queries generated by EF6 convert .NET DateTime type to TIMESTAMP. So the query performance is very poor.
I tried to add a precision to 0 for the DATETIME columns but nothing changes on the generated query.
Property(_ => _.MyDate).HasColumnName("DATE_COLUMN").HasPrecision(0);
How can I specify in my code to translate my where clause by a TO_DATE function and not by a TO_TIMESTAMP function ?
I've had a similar issue with DATE Oracle type and EF6.1. My workaround was to use the CodeFirstFunctions library (available only for EF6.1 and later) and specify a conversion function first in Oracle:
And later in my DbContext:
So I can force Entity Framework to use DATE type in a where condition:
Be careful to use capital letters for the function name and for the schema name with CodeFirstFunctions if you use Oracle.
If you need more details I've written a blog post about this with an example project.