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

asp.net-mvc c# effort entity-framework-6 spatial

Question

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

Accepted Answer

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.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why