简体   繁体   中英

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

I'm developing an application with EF6 and I decided to use System.Data.Entity.Spatial.DbGeography for my locations as follows

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

When I run my tests I get the following error

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: I'm using Effort for my tests.

Any suggestion would be helpful, thanks.


Edited 03/04/15:

The error is with Effort. It doesn't support spatial properties [DbGeography] I'm looking for a workaround which I will post when I solved the issue.

More info: https://effort.codeplex.com/discussions/471666

Given that Effort doesn't not support special properties like DbGeography and tamasflamich says here :

There is no existing support (not even beta) and I am not planning to start work on this feature anytime soon. Sorry.

I also tried to use Highway.Data but it doesn't support neither.

It does not now, nor will it ever support AdvancedQuery, AdvancedCommand, or AdvancedScalar.

I walked through my code and notice that I only need the locations inside of a box, then I decided to stop using DbGeography and do it by my own, as follows:

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

Instead of:

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

Now I have this:

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

This solved my problem but would be great that Effort and HighwayFramework support spatial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM