How would I map Spatial Data for EF Core 3.x?

LINQPad 6 seems to completely skip spatial data types such as IGeography.

I'm following the official docs from Microsoft: https://docs.microsoft.com/en-us/ef/core/modeling/spatial

I'm using the "(Entity Framework Core (multi-provider)" driver in LinqPad 6 Ef Core 3.0
Couldn't get it work on EF Core 2.x either.

Any help on mapping Geography data types automatically would be greatly appreciated.
Thanks in advance!


  • Undocumented, package NetTopologySuite.Core is also required (which I've included).
  • Are you saying that adding NetTopologySuite.Core fixes the problem, or does it make no difference?
  • Adding NetTopologySuite.Core does not fix the problem in LinqPad.
    I believe this is because LinqPad is not referencing the required spatial geography packages NetTopologySuite.Core package and Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite package when creating the custom DBContext for the (Entity Framework Core (multi-provider) option.

    I was able to confirm this by clicking the “Show Assembly Resolution Log”, I didn't see the required package for SQL Server, resulting in EF Core skipping all geography columns.

    According to Microsoft, there’s a separate Spatial Geography package required for each EF Core Provider:
    EF Core Provider Required Spatial NuGet Package
    Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
    Microsoft.EntityFrameworkCore.Sqlite Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite
    Microsoft.EntityFrameworkCore.InMemory NetTopologySuite
    Npgsql.EntityFrameworkCore.PostgreSQL Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite

    An additional package NetTopologySuite.Core is also required regardless of the EF Core Provider.

    In a Visual Studio project, I was able to successfully scaffold the geography type for SQL Server when I included the Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
    and NetTopologySuite.Core packages in the project.

    It would be great if LinqPad would automatically include the Spatial Geography packages listed above when using the (Entity Framework Core (multi-provider) option, as it would save us the time from creating a separate project and building a DLL to use spatial data. The Entity Framework Core (multi-provider) option is much more convenient!

    Thanks in advance!
  • Are there any developments on this subject? I cannot query point type fields with linqpad.

  • I've added spatial support to the EF Core driver in the latest beta (6.9.3). Let me know how you get along. Note that right now, it works with SQL Server only. Also, you need to enable the option via a checkbox in the connection properties dialog.

  • The latest beta 6.9.11 does not have a check box for enabling UseNetTopologySuite

  • Does your dialog look like this?

  • I was connecting through a typed context not the EF Core Connection. Just loaded the latest beta and it is connecting fine now (not throwing an error on the Point data type). Thanks!

Sign In or Register to comment.