dotConnect for PostgreSQL Documentation
In This Topic
    Entity Framework Data Type Mapping
    In This Topic

    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 - 2022 and Create Model Wizard in Entity Developer.

    PostgreSQL data types

    SSDL1

    CSDL1

    .NET

    boolean boolean Boolean System.Boolean
    smallint, int2 smallint Int16 System.Int16
    integer, int4 int Int32 System.Int32
    bigint, int8 bigint Int64 System.Int64
    real real Single System.Single
    double precision, money double precision Double System.Double
    numeric, decimal, float numeric, decimal, float Decimal System.Decimal
    date, timestamp, timestamp with time zone, timestamp without time zone date, timestamp, timestamptz DateTime System.DateTime
    time, time with time zone, time without time zone, interval time, timetz, interval Time System.TimeSpan
    timestamp with time zone datetimeoffset DateTimeOffset System.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, jsonb char, varchar, text, citext, enum, bit, varbit, cidr, inet, macaddr, point, line, lseg, box, path, polygon, circle, xml, json, jsonb String System.String
    bytea bytea Binary System.Byte[]
    uuid2 uuid Guid System.Guid
    geometry3 spatial_geometry Geometry, GeometryCollection, GeometryLineString, GeometryMultiLineString, GeometryMultiPoint, GeometryMultiPolygon, GeometryPoint, GeometryPolygon System.Data.Spatial.DbGeometry
    geography3 spatial_geography Geography, GeographyCollection, GeographyLineString, GeographyMultiLineString, GeographyMultiPoint, GeographyMultiPolygon, GeographyPoint, GeographyPolygon System.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.Boolean Boolean boolean boolean
    System.Byte Byte byte smallint
    System.Byte[] Binary bytea bytea
    System.Data.Spatial.DbGeometry2 Geometry spatial_geometry geometry
    System.Data.Spatial.DbGeography2 Geography spatial_geography geography
    System.DateTime DateTime timestamp timestamp
    System.DateTimeOffset DateTimeOffset datetimeoffset timestamp with time zone
    System.Decimal Decimal numeric numeric
    System.Double Double double precision double precision
    System.Guid Guid uuid uuid
    System.Int16 Int16 smallint smallint
    System.Int32 Int32 int integer
    System.Int64 Int64 bigint bigint
    System.SByte SByte sbyte smallint
    System.Single Single real real
    System.String String char, varchar char, varchar
    System.TimeSpan Time timestamp timestamp

    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.