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.
MySQL data types | SSDL1 | CSDL1 | .NET |
|---|---|---|---|
| bool, boolean, bit(1) | boolean | Boolean | System.Boolean |
| tinyint | sbyte | SByte | System.SByte |
| tinyint unsigned | tinyint | Byte | System.Byte |
| smallint, year | smallint | Int16 | System.Int16 |
| int, integer, smallint unsigned, mediumint | int | Int32 | System.Int32 |
| bigint, int unsigned, integer unsigned, bit | bigint | Int64 | System.Int64 |
| float | float | Single | System.Single |
| double, real | double | Double | System.Double |
| decimal, numeric, dec, fixed, bigint unsigned, float unsigned, double unsigned, serial | decimal | Decimal | System.Decimal |
| date, timestamp, datetime | date, timestamp, datetime | DateTime | System.DateTime |
| time | time | Time | System.TimeSpan |
| char, varchar, tinytext, text, mediumtext, longtext, set, enum, nchar, national char, nvarchar, national varchar, character varying | char, varchar, tinytext, text, mediumtext, longtext, set, enum | String | System.String |
| binary, varbinary, tinyblob, blob, mediumblob, longblob, char byte | binary, varbinary, tinyblob, blob, mediumblob, longblob | Binary | System.Byte[] |
| geometry2 | spatial_geometry | Geometry, GeometryCollection, GeometryLineString, GeometryMultiLineString, GeometryMultiPoint, GeometryMultiPolygon, GeometryPoint, GeometryPolygon | System.Data.Spatial.DbGeometry |
| geometry2 | spatial_geography | Geography, GeographyCollection, GeographyLineString, GeographyMultiLineString, GeographyMultiPoint, GeographyMultiPolygon, GeographyPoint, GeographyPolygon | System.Data.Spatial.DbGeography |
1 Applicable only to Entity Framework v1 - v6. Not applicable to Entity Framework Core, because Entity Framework Core does not support XML mapping.
2 Supported in Entity Framework v5 and v6.
.NET | CSDL1 | SSDL1 | MySQL data types |
|---|---|---|---|
| System.Boolean | Boolean | boolean | boolean, bit(1) |
| System.Byte | Byte | tinyint | tinyint unsigned |
| System.Byte[] | Binary | binary, varbinary, blob, longblob | binary, varbinary, blob, longblob |
| System.Data.Spatial.DbGeometry2 | Geometry | spatial_geometry | geometry |
| System.Data.Spatial.DbGeography2 | Geography | spatial_geography | geometry |
| System.DateTime | DateTime | datetime | datetime |
| System.DateTimeOffset | DateTimeOffset | datetimeoffset | datetime |
| System.Decimal | Decimal | decimal | decimal |
| System.Double | Double | double | double |
| System.Guid | Guid | guid | char(36) |
| System.Int16 | Int16 | smallint | smallint |
| System.Int32 | Int32 | int | int |
| System.Int64 | Int64 | bigint | bigint |
| System.SByte | SByte | sbyte | tinyint |
| System.Single | Single | float | float |
| System.String | String | char, varchar, text, longtext | char, varchar, text, longtext |
| System.TimeSpan | Time | time | time |
1 Applicable only to Entity Framework v1 - v6. Not applicable to Entity Framework Core, because Entity Framework Core does not support XML mapping.
2 Supported in Entity Framework v5 and v6.