11// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22
3+ using EntityFrameworkCore . Jet . Data ;
34using System . Collections ;
45using System . Data ;
56using System . Text . Json ;
@@ -49,7 +50,7 @@ public class JetTypeMappingSource : RelationalTypeMappingSource
4950 private readonly JetStringTypeMapping _variableLengthUnicodeString = new ( "varchar" , unicode : true ) ;
5051 private readonly JetStringTypeMapping _variableLengthMaxUnicodeString = new ( "varchar" , unicode : true , size : 255 , storeTypePostfix : StoreTypePostfix . Size ) ;
5152 private readonly JetStringTypeMapping _unboundedUnicodeString = new ( "longchar" , unicode : true , storeTypePostfix : StoreTypePostfix . None ) ;
52- private readonly JetGuidTypeMapping _guid = new ( "uniqueidentifier" , DbType . Guid ) ;
53+ private readonly JetGuidTypeMapping _guid ;
5354 private readonly JetByteArrayTypeMapping _rowversion = new ( "varbinary" , size : 8 ,
5455 comparer : new ValueComparer < byte [ ] > (
5556 ( v1 , v2 ) => StructuralComparisons . StructuralEqualityComparer . Equals ( v1 , v2 ) ,
@@ -78,6 +79,10 @@ public JetTypeMappingSource(
7879 // https://support.office.com/en-us/article/equivalent-ansi-sql-data-types-7a0a6bef-ef25-45f9-8a9a-3c5f21b5c65d
7980 // https://sourcedaddy.com/ms-access/sql-data-types.html
8081
82+ _guid = options . DataAccessProviderType == DataAccessProviderType . Odbc
83+ ? new JetOdbcGuidTypeMapping ( "uniqueidentifier" )
84+ : new JetGuidTypeMapping ( "uniqueidentifier" , DbType . Guid ) ;
85+
8186 // TODO: Check the types and their mappings against
8287 // https://docs.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140015(v=office.10)
8388
@@ -87,7 +92,7 @@ public JetTypeMappingSource(
8792 _dateonly = new JetDateOnlyTypeMapping ( "date" , options , dbType : DbType . Date ) ;
8893 _timeonly = new JetTimeOnlyTypeMapping ( "time" , options ) ;
8994 _timespan = new JetTimeSpanTypeMapping ( "datetime" , options ) ;
90-
95+
9196 _storeTypeMappings
9297 = new Dictionary < string , RelationalTypeMapping [ ] > ( StringComparer . OrdinalIgnoreCase )
9398 {
0 commit comments