in EFCore/src/Storage/Internal/MySQLTypeMappingSource.cs [103:225]
protected void Initialize()
{
if (guidFormat == MySqlGuidFormat.Default)
{
guidFormat = _options.ConnectionSettings.OldGuids
? MySqlGuidFormat.LittleEndianBinary16
: MySqlGuidFormat.Char36;
}
_guid = MySQLGuidTypeMapping.IsValidGuidFormat(guidFormat)
? new MySQLGuidTypeMapping(guidFormat)
: null;
_storeTypeMappings = new Dictionary<string, RelationalTypeMapping[]>(StringComparer.OrdinalIgnoreCase)
{
// integers
{ "bigint", new[] { _bigint } },
{ "bigint unsigned", new[] { _ubigint } },
{ "int", new[] { _int } },
{ "int unsigned", new[] { _uint } },
{ "integer", new[] { _int } },
{ "integer unsigned", new[] { _uint } },
{ "mediumint", new[] { _int }},
{ "mediumint unsigned",new[] { _uint }},
{ "smallint", new[] { _smallint }},
{ "smallint unsigned", new[] { _usmallint }},
{ "tinyint", new[] { _tinyint }},
{ "tinyint unsigned", new[] { _utinyint }},
// decimals
{ "decimal", new[] { _decimal }},
{ "numeric",new[] { _decimal }},
{ "dec", new[] { _decimal }},
{ "fixed",new[] { _decimal }},
{ "double",new[] { _double }},
{ "float", new[] { _float }},
{ "real",new[] { _double }},
// binary
{ "binary", new[] { _binary }},
{ "varbinary",new[] { _varbinary }},
{ "tinyblob", new[] { _varbinary }},
{ "blob",new[] { _varbinary }},
{ "mediumblob",new[] { _varbinary }},
{ "longblob",new[] { _varbinary }},
// string
{ "char",new[] { _charUnicode }},
{ "varchar",new[] { _varcharUnicode }},
{ "nchar", new[] { _nchar }},
{ "nvarchar", new[] { _nvarchar }},
{ "tinytext",new[] { _tinyTextUnicode }},
{ "text", new[] { _textUnicode }},
{ "mediumtext", new[] { _mediumTextUnicode }},
{ "longtext",new[] { _longtextUnicode }},
{ "enum",new[] { _enum }},
{ "set",new[] { _set }},
// DateTime
{ "year",new[] { _int }},
{ "date", new RelationalTypeMapping[] { _date, _dateonly }},
{ "time", new RelationalTypeMapping[] { _time, _timeonly }},
{ "timestamp", new RelationalTypeMapping[] { _timeStamp, _timestampoffset }},
{ "datetime", new RelationalTypeMapping[] { _datetime, _datetimeoffset }},
// bit
{ "bit",new[] { _bit }},
// other
{ "geometry", new[] { _geometry }},
{ "json", new[] { _longtextUnicode } }
};
_clrTypeMappings = new Dictionary<Type, RelationalTypeMapping>
{
// integers
{ typeof(short), _smallint },
{ typeof(ushort), _usmallint },
{ typeof(int), _int },
{ typeof(uint), _uint },
{ typeof(long), _bigint },
{ typeof(ulong), _ubigint },
// byte / char
{ typeof(byte), _utinyint },
{ typeof(sbyte), _tinyint },
#if !NET8_0_OR_GREATER
// DateTime
{ typeof(DateTime), _datetime.Clone(6, null) },
{ typeof(DateOnly), _dateonly },
{ typeof(DateTimeOffset), _datetimeoffset.Clone(6, null) },
{ typeof(TimeSpan), _time.Clone(6, null) },
{ typeof(TimeOnly), _timeonly },
#else
// DateTime
{ typeof(DateTime), _datetime.WithPrecisionAndScale(6, null) },
{ typeof(DateOnly), _dateonly },
{ typeof(DateTimeOffset), _datetimeoffset.Clone() },
{ typeof(TimeSpan), _time.WithPrecisionAndScale(6, null) },
{ typeof(TimeOnly), _timeonly },
#endif
// decimals
{ typeof(float), _float },
{ typeof(double), _double },
{ typeof(decimal), _decimal },
{ typeof(Data.Types.MySqlGeometry), _geometry }
};
// bool
bool tinyAsBool = _options.ConnectionSettings.TreatTinyAsBoolean;
_storeTypeMappings[tinyAsBool ? "tinyint(1)" : "bit(1)"] = new RelationalTypeMapping[] { tinyAsBool ? _tinyintBool : _bitBool };
_clrTypeMappings[typeof(bool)] = tinyAsBool ? _tinyintBool : _bitBool;
// Guid
if (_guid != null)
{
_storeTypeMappings[_guid!.StoreType] = new RelationalTypeMapping[] { _guid };
_clrTypeMappings[typeof(Guid)] = _guid;
}
}