Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read / write geography data using C#, Entity Framework and SQL Server 2008?

I have a form from which the user will be able to enter the latitude and longitude of a certain point on the map. The data will be input as string values. I did some research and found out from various sources that the Entity Framework doesn't support geography data types.

  • How can I parse and/or save the string data to a geography column in a database?
  • How can I access it and reparse it as string once it is stored?

Thanks in advance!

like image 234
Filip Filipović Avatar asked May 18 '12 15:05

Filip Filipović


1 Answers

In fact Entity Framework 5 components that are shipped with .NET Framework 4.5 do support spatial types. Take a look at this walkthrough.

EDIT With EF6 you can use spatial types on both .NET Framework 4 and .NET Framework 4.5

like image 80
Pawel Avatar answered Sep 23 '22 11:09

Pawel