title: Calculate the geographic distance between two points using NetTopologySuite with EF Core and postgis
body: <p>I am using the <a href="https://hub.docker.com/r/kartoza/postgis/" rel="nofollow noreferrer">kartoza</a> docker image to run a postgres server with postgis. I have a database which I am consuming using an ASP.NET Core application and Enity Framework Core. The database contains a table named Park which is represented by the following entity:</p>
  
  <pre><code>[Table("Park")]
  public class Park
  {
       [Key]
       public int Id { get; set; }
  
       [Column(TypeName = "geography (point)")]
       public Point Location { get; set; }
  }
  </code></pre>
  
  <p>I am creating the DbContext as specified by the documentation:</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
      modelBuilder.HasPostgresExtension("postgis");
  
      modelBuilder.Entity&lt;Park&gt;()
          .Property(p =&gt; p.Location)
          .HasColumnType("geography (point)");
  }
  </code></pre>
  
  <p>I seed the database with the following code:</p>
  
  <pre><code>if (!Parks.Any())
  {
      var park = new Park
      {
          Location = new Point(48.8566, 2.3522)
          {
              SRID = 4326
          }
      };
  
      Parks.Add(park);
      this.SaveChanges();
  }
  </code></pre>
  
  <p>Now to test my code, I calculate the distance between this park and some point:</p>
  
  <p><a href="https://i.stack.imgur.com/kulEX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kulEX.png" alt="enter image description here"></a></p>
  
  <p>The result correspond to the geometric distance between the two points in a cartesian frame, not the geographic distance. Is it possibe to get the equivalent of the following query:</p>
  
  <p><a href="https://i.stack.imgur.com/rjx7O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjx7O.png" alt="rap"></a></p>