dotConnect for PostgreSQLsupport@devart.com

Entity Framework Data Type Mapping

PostgreSQL to .NET type mapping

Type mapping rules from this table are used when generating a model from a database with Entity Data Model Wizard in Visual Studio 2008 - 2015 and Create Model Wizard in Entity Developer.

PostgreSQL data types

SSDL1

CSDL1

.NET

booleanbooleanBooleanSystem.Boolean
smallint, int2smallintInt16System.Int16
integer, int4intInt32System.Int32
bigint, int8bigintInt64System.Int64
realrealSingleSystem.Single
double precision, moneydouble precisionDoubleSystem.Double
numeric, decimal, floatnumeric, decimal, floatDecimalSystem.Decimal
date, timestamp, timestamp with time zone, timestamp without time zonedate, timestamp, timestamptzDateTimeSystem.DateTime
time, time with time zone, time without time zone, intervaltime, timetz, intervalTimeSystem.TimeSpan
timestamp with time zonedatetimeoffsetDateTimeOffsetSystem.DateTimeOffset
char, varchar, text, citext, enum, bit, varbit, cidr, inet, macaddr, point, line, lseg, box, path, polygon, circle, xml*, character, character varying, bit varying, json, jsonbchar, varchar, text, enum, bit, varbit, cidr, inet, macaddr, point, line, lseg, box, path, polygon, circle, xml, json, jsonbStringSystem.String
byteabyteaBinarySystem.Byte[]
uuid2uuidGuidSystem.Guid
geometry3spatial_geometryGeometry, GeometryCollection, GeometryLineString, GeometryMultiLineString, GeometryMultiPoint, GeometryMultiPolygon, GeometryPoint, GeometryPolygonSystem.Data.Spatial.DbGeometry
geography3spatial_geographyGeography, GeographyCollection, GeographyLineString, GeographyMultiLineString, GeographyMultiPoint, GeographyMultiPolygon, GeographyPoint, GeographyPolygonSystem.Data.Spatial.DbGeography

1 Note that when mapping corresponding database data type, you will need the .NET type with larger precision. That is because, for example, any Int32 value can be stored in the NUMBER(10) column, but largest NUMBER(10) column value cannot be stored in the Int32 field, it requires Int64 field.

2 Uuid and xml data types appeared in PostgreSQL 8.3.

3 Supported in Entity Framework v5 and v6.

.NET to PostgreSQL default type mapping

.NET

CSDL1

SSDL1

PostgreSQL data types

System.BooleanBooleanbooleanboolean
System.ByteBytebytesmallint
System.Byte[]Binarybyteabytea
System.Data.Spatial.DbGeometry2Geometryspatial_geometrygeometry
System.Data.Spatial.DbGeography2Geographyspatial_geographygeography
System.DateTimeDateTimetimestamptimestamp
System.DateTimeOffsetDateTimeOffsetdatetimeoffsettimestamp with time zone
System.DecimalDecimalnumericnumeric
System.DoubleDoubledouble precisiondouble precision
System.GuidGuiduuiduuid
System.Int16Int16smallintsmallint
System.Int32Int32intinteger
System.Int64Int64bigintbigint
System.SByteSBytesbytesmallint
System.SingleSinglerealreal
System.StringStringchar, varcharchar, varchar
System.TimeSpanTimetimestamptimestamp

1 Note that when mapping corresponding database data type, you will need the .NET type with larger precision. That is because, for example, any Int32 value can be stored in the NUMBER(10) column, but largest NUMBER(10) column value cannot be stored in the Int32 field, it requires Int64 field.

2 Supported in Entity Framework v5 and v6.

DateTimeOffcet type is not supported.

 

 


© 2003 - 2016 Devart. All rights reserved.