【发布时间】:2019-10-17 15:06:16
【问题描述】:
我正在寻找如何在实体框架中实现所有 Oracle 函数。我一直在做一些研究,但大多数信息都指向确保函数列在 .edmx 文件中。问题是我使用的是数据库优先方法,而使用 Oracle 驱动程序我看不到存储的过程或函数,所以我没有使用 .emdx 文件。
我发现一篇文章显示手动将函数添加到我的 DataContext 文件。我试图跟随这段代码,但我收到一个错误,它不知道“FunctionsConvention”。这就是我放入 DataContext 中的内容。
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add(new FunctionsConvention("dbo", this.GetType()));
}
[DbFunction("CodeFirstDatabaseSchema", "LatLongDistanceCalc")]
public static int LatLongDistanceCalc(int fromLat, int fromLong, int toLat, int toLong)
{
// no need to provide an implementation
throw new NotSupportedException();
}
任何人都知道我如何在我的 EF 中添加一个函数,或者有一个文章链接可以提供帮助吗?
【问题讨论】:
标签: c# oracle entity-framework-6