Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using DbGeography Tyes with Entity Framework 7 and vNext

I am building an application that will use Spatial Data with vNext and EF7. In the past with the current version of asp.net and EF6 I have used System.Data.Entity.Spatial in order to use the DbGeography however now this namespace is not available.

Currently I have the following nuget packages in my project.json file:

  • "EntityFramework.Commands": "7.0.0-rc1-final"
  • "EntityFramework.Core": "7.0.0-rc1-final"
  • "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"

Is there a package that I am missing, or is support for Spatial Data Types with SQL Server something that has not been implemented yet? I notice that there is a backlog feature marked ‘Modelling - Complex/value types’ on the EF7 github Roadmap, but I don’t see any specifics.

If there is a package I am missing, what is the package so I can include it.

Many thanks in advance

like image 529
user3060716 Avatar asked Oct 30 '22 12:10

user3060716


1 Answers

Spatial data isn't supported yet by Entity Framework Core.

"Spatial is not planned for 2.0 and we haven’t finished planning for the version after. It might be a good idea to post more details about what you would like to have in spatial support at github.com/aspnet/EntityFramework/issues/1100, e.g. do you use specific spatial functions or do you need rich spatial types with all kinds of spatial functionality, would you use this only with a specific database or do you need to write the same code against multiple databases? Etc."

Source:

http://github.com/aspnet/EntityFramework/issues/1100 https://blogs.msdn.microsoft.com/dotnet/2017/06/28/announcing-ef-core-2-0-preview-2/

Altought I have made a temporary workaround to include Geography column and use it in EF Core 1.0.0 and above. (It's not perfect, but it will do for now)

See the accepted answer on:

Entity Framework Core: Type Udt is not supported on this platform. (Spatial Data - Geography)

like image 196
Eli Avatar answered Nov 15 '22 04:11

Eli