代码改变世界

在使用EF时调用DBFUNCTION扩展方法时,发生ENTITYCOMMANDEXECUTIONEXCEPTION 异常的解决办法

2015-10-30 14:04  咒语  阅读(1955)  评论(0编辑  收藏  举报
System.Data.Entity.Core.EntityCommandExecutionException : An error occurred while executing the command definition. See the inner exception for details.
----> MySql.Data.MySqlClient.MySqlException : FUNCTION EEManageDb.DiffDays does not exist
 

其实提示的已经很清楚了。没有DiffDays这个函数,自已定义一下就行了。

产生这个异常的原因是:由于使用EF时lamdag表达式中的时间比较不能直接比较,需要通过EF的扩展的DBFunction来进行调用,并且同时DB中也要有这个函数才行。