簡體   English   中英

Effort.EF6的空間DbGeography Provider異常[找不到可用的空間提供商。]

[英]Spatial DbGeography Provider exception with Effort.EF6 [No usable spatial provider could be found.]

我正在使用EF6開發應用程序,因此決定將System.Data.Entity.Spatial.DbGeography用於我的位置,如下所示

public class Place
{
  public int Id { get; set; }
  public string Name { get; set; }
  public DbGeography Location { get; set; }
} 

當我運行測試時,出現以下錯誤

System.NotImplementedException : No usable spatial provider could be found. In order to use the 'DbGeography' or 'DbGeometry' spatial types the EF provider being used must support spatial types and all prerequisites for the provider must be installed.

PS:我正在努力進行測試。

任何建議都會有所幫助,謝謝。


編輯於03/04/15:

錯誤在於努力。 它不支持空間屬性[DbGeography]我正在尋找一種解決方法,當我解決該問題時將發布該解決方法。

更多信息: https : //effort.codeplex.com/discussions/471666

鑒於Effort不支持DbGeography之類的特殊屬性,而tamasflamich 在這里說:

目前沒有任何支持(甚至沒有beta版),而且我不打算很快就開始使用此功能。 抱歉。

我也嘗試使用Highway.Data,但它都不支持。

它現在不支持,也不支持AdvancedQuery,AdvancedCommand或AdvancedScalar。

我瀏覽了我的代碼,發現我只需要一個盒子內的位置,然后我決定停止使用DbGeography並由我自己做,如下所示:

public class Place
{
  public int Id { get; set; }
  public string Name { get; set; }
  public double Lat { get; set; }
  public double Lng { get; set; }
}

代替:

public IEnumerable<Church> GetInBox(DbGeography boundingBox)
{
  return All().Where(c => c.Location.Intersects(boundingBox));
}

現在我有這個:

public IEnumerable<Church> GetInBox(DbGeography boundingBox)
{
  All().Where(c =>
            c.Lat <= nelt &&
            c.Lat >= swlt &&
            c.Lng <= nelng &&
            c.Lng >= swlng
            );
}

這解決了我的問題,但是Effort和HighwayFramework支持空間功能將非常棒。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM