This topic is applicable to Entity Framework v5 and v6. For Entity Framework Core, see Spatial Data Support for EF Core.
In PostgreSQL, the 'geometry' and 'geography' PostGIS data types are used to represent spatials. Entity Framework 5 uses DbGeometry and DbGeography types from the System.Data.Entity.dll assembly for this purpose (.NET Framework 4.5). Entity Framework 6 uses DbGeometry and DbGeography types from the EntityFramework.dll (.NET Framework 4.0 and .NET Framework 4.5).
When using XML mapping spatial types are mapped in the following way in edmx/edml files:
PostGIS data types | SSDL | CSDL | .NET |
---|---|---|---|
geometry | spatial_geometry | Geometry, GeometryCollection, GeometryLineString, GeometryMultiLineString, GeometryMultiPoint, GeometryMultiPolygon, GeometryPoint, GeometryPolygon | DbGeometry |
geography | spatial_geography | Geography, GeographyCollection, GeographyLineString, GeographyMultiLineString, GeographyMultiPoint, GeographyMultiPolygon, GeographyPoint, GeographyPolygon | DbGeography |
dotConnect for PostgreSQL supports PostGIS 2.0 or higher.