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

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

    SQLite data types

    SSDL1

    CSDL1

    .NET

    boolean boolean Boolean System.Boolean
    tinyint tinyint Byte System.Byte
    smallint, int16 smallint Int32 System.Int16
    int, int32 int32 Int32 System.Int32
    INTEGER, int64 integer Int64 System.Int64
    REAL real Double System.Double
    NUMERIC, decimal, money, currency numeric, decimal, money, currency Decimal System.Decimal
    date, time, datetime, smalldate date, time, datetime, smalldate DateTime System.DateTime
    datetimeoffset datetimeoffset DateTimeOffset System.DateTimeOffset
    time time Time System.TimeSpan
    TEXT, ntext, char, nchar, varchar, nvarchar, string text, ntext, char, nchar, varchar, nvarchar, string String System.String
    BLOB, binary, varbinary, image, general blob, binary, varbinary, image, general Binary System.Byte[]
    guid guid Guid System.Guid

    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.

    .NET to SQLite default type mapping

    .NET

    CSDL1

    SSDL1

    SQLite data types

    System.Boolean Boolean boolean boolean
    System.Byte Byte tinyint INTEGER
    System.Byte[] Binary blob BLOB
    System.DateTime DateTime datetime datetime
    System.DateTimeOffset DateTimeOffset datetimeoffset datetimeoffset
    System.Decimal Decimal numeric NUMERIC
    System.Double Double real REAL
    System.Guid Guid guid guid
    System.Int16 Int16 smallint INTEGER
    System.Int32 Int32 int32 INTEGER
    System.Int64 Int64 integer INTEGER
    System.SByte SByte sbyte INTEGER
    System.Single Single single REAL
    System.String String text TEXT
    System.TimeSpan Time time time

    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.

    DateTimeOffset type is not supported.