Search code examples
entity-framework-coreazure-sql-databaseazure-maps

How do I create a spatial index in Entity Framework?


I have the class:

public class Address
{
    // street, city, etc.

    /// <summary>
    /// use X for longitude and Y for latitude.
    /// </summary>
    public NetTopologySuite.Geometries.Point? Location { get; set; }
}

How in Entity Framework do I tell it to create a spatial index for Address.Point?


Solution

  • You wouldn't create a spatial index in entity framework, you would create that in your spatial database. Entity framework builds queries that then call the database, the database processes the query and thus would need the spatial index. So you would have to go into your database manager and add the spatial index there. Once added, spatial queries should automatically make use of it.