我正在用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,我正在寻找一个解决方法,当我解决这个问题时,我会发布这个解决方法。
发布于 2015-03-04 20:04:22
考虑到这种努力不支持像DbGeography和tamasflamich这样的特殊特性,这里说
没有现有的支持(甚至没有测试版),我也不打算在短期内开始这项功能。抱歉的。
我也尝试使用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
);
}这解决了我的问题,但这将是伟大的努力和HighwayFramework支持空间。
https://stackoverflow.com/questions/28764955
复制相似问题