dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.82k stars 3.2k forks source link

Improve the experience of working with spatial types using OData and EF Core #27861

Open JeremyLikness opened 2 years ago

JeremyLikness commented 2 years ago

Related to Issue #22951

Currently, EF Core recognizes spatial types based on the NetTopologySuite (NTS) while OData recognizes the types in Microsoft.Spatial. This means there is no "easy path" to using spatial with both EF Core and OData, but a complicated set of customizations like the ones described in Customizing $filter for spatial data in ASP.NET Core OData 8. .NET developers deserve a streamlined experience here.

There are two solutions @bricelam suggested:

  1. The EF Core team provides a set of packages that enable use of Microsoft.Spatial types, so OData will "just work", or
  2. The OData team provides an extension that recognizes NTS types, and EF Core will "just work"
bricelam commented 2 years ago

One caveat to using Microsoft.Spatial types in your EF Core model is that your queries are limited to the spatial operations available on those types. Today, that's only three operations: Distance, Intersects, and Length. Also, there is no client-side implementation of these operations--they just throw NotImplementedException. (Easy to see why we went with NTS, isn't it?)