LinqPad 5:当前上下文中不存在名称 'DbFunctions'

LinqPad 5 : The name 'DbFunctions' does not exist in the current context

我正在尝试在 LinqPad 中使用以下内容(C# 语句):

DbFunctions.TruncateTime(mvOutDt).ToString()

它似乎无法识别 DbFunctions。我添加了 System.Data.Entity 参考。我什至尝试使用 System.Data.Entity.DbFunctions 完全限定它,但没有成功。

感谢任何帮助。

您使用的版本不正确。

DbFunctions class 是在 Entity Framework 6 中引入的,可通过 NuGet 包获得。

如果您使用的是 EF 5 或更早版本,根据 documentation.[=15=,您将不会在 System.Data.Entity 命名空间中找到 DbFunctions class ]