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 |
| bool | bit | boolean | INTEGER | |
| byte | tinyint |
smallint (Postgres lack tinyint) |
INTEGER | |
| short | smallint | smallint | INTEGER | |
| int (32-bit) | int | integer | INTEGER | |
| long (64-bit) | bigint | bigint | INTEGER | |
| decimal | decimal(18,2) |
numeric(18,2) Adjustable for domain |
REAL | |
| float | real | real | REAL | |
| double | float | double precision | REAL | |
| Guid | uniqueidentifier | uuid | TEXT | |
| string | nvarchar(max) | text | TEXT | |
| char | nchar(1) | char(1) | TEXT | |
| byte[] | varbinary(max) | bytea | BLOB | |
| DateTime | datetime2 | timestamp without time zone |
TEXT Use ISO-8601 text for SQLite |
|
| DateTimeOffset | datetimeoffset | timestamp with time zone | TEXT | |
| TimeSpan | time | interval | TEXT | |
|
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 |
jsonb Native JSON support |
TEXT |
No Comments