【问题标题】:LinqPad 5 : The name 'DbFunctions' does not exist in the current contextLinqPad 5:当前上下文中不存在名称“DbFunctions”
【发布时间】:2016-07-20 02:48:20
【问题描述】:

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

DbFunctions.TruncateTime(mvOutDt).ToString()

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

感谢任何帮助。

【问题讨论】:

  • 我无法在 LinqPad 5 中重现这一点。工作得很好。你确定你添加了正确的 nuget 包版本吗?
  • 是的,我的同事在他的身上试过,效果很好。我不认为它有一个 nuget 包。 System.Data.Entity 内置

标签: c# linqpad dbfunctions


【解决方案1】:

您使用的版本不正确。

DbFunctions class 是在实体框架 6 中引入的,可通过 NuGet 包获得。

如果您使用的是 EF 5 或更早版本,则根据 documentation,您将无法在 System.Data.Entity 命名空间中找到 DbFunctions 类。

【讨论】:

  • 它是什么样子的......我使用的是基本版本,它不允许我获得 Entity Framework 6 包......我的同事有高级版本。所以你可能是对的。
  • 这可能会做到。您正在从 .NET Framework 安装版本中提取 EF 5 或更早版本。
猜你喜欢
  • 2023-03-09
  • 1970-01-01
  • 2013-10-02
  • 2014-04-22
  • 2017-06-17
  • 2015-09-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多