Skip to main content

EF - Backend vs .NET Datatypes

Here's a list of what datatypes that Entity Framework uses to store .NET datatypes in a couple different database engines.

.NET Datatype SQL Server PostgreSQL SQLite Comments
boolbitbooleanINTEGER
bytetinyint

smallint

(Postgres lack tinyint)

INTEGER
shortsmallintsmallintINTEGER
int (32-bit) int integer INTEGER
long (64-bit) bigint bigint INTEGER
shortsmallintsmallintINTEGER
bytetinyint

smallint

(Postgres lack tinyint)

INTEGER
boolbitbooleanINTEGER
decimal decimal(18,2)

numeric(18,2)

Adjustable for domain

REAL
doublefloatdouble precisionREAL
float real real REAL
DateTimedouble datetime2float timestampdouble without time zoneprecision TEXT
DateTimeOffsetdatetimeoffsettimestamp with time zoneTEXT
TimeSpantimeintervalTEXTREAL
Guid uniqueidentifier uuid TEXT
string nvarchar(max) text TEXT
charnchar(1)char(1)TEXT
byte[] varbinary(max) bytea BLOB
char[]DateTime nvarchar(max)datetime2 Nottimestamp supportedwithout time zone Not supported

TEXT

Use ISO-8601 text for SQLite


DateTimeOffsetdatetimeoffsettimestamp with time zoneTEXT
TimeSpantimeintervalTEXT

JsonDocument /

Dictionary<string, object>

nvarchar(max)

SQL Server has no native JSON type; EF stores as text.

jsonb

Native JSON support

TEXT
object

sql_variant

Only if configured manually

Not supportedNot supported
IPAddress / PhysicalAddressNot supportedinet / macaddrNot supported
List<T> / array

Not supported

type[]jsonb

nativeNative arrayJSON support

Not supportedTEXT