{%Pragmatic Coding%} Tips and tricks for software developers.

2Jan/140

Canonical Function “EntityFunctions.TruncateTime” does not exist in MYSQL

In our project we are using CodeFirst EF and MySQL database. And I had to make some queries that excludes time from comparison. But when I tried to use "EntityFunctions.TruncateTime" function as I could use it with regular LINQ and MS SQL I've got an error {"FUNCTION [database].TruncateTime does not exist"}.

While researching network I found that EF v.4 and upper should support this function, but unfortunately it does not work for me, so I have found best solution is to create custom function for MySQL:

And now you can simply use it in your code:

Hope this article was helpful.

Tagged as: C#, mysql, sql No Comments