繁体   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