GUIDs getting stored in SQL Lite upper case which causes FK's to fail

I have a number of tables which use GUID as the PK. When I insert into these tables using Locode, the AUTOID GUID’s that get generated appear to be in upper case.

I have looked through the SqliteGuidConverter and can’t see where this is happening and even if I check the profiling, the SQL query does not appear to upper case it.

The issue is that I then try to insert into other tables that have these columns as foreign keys and they will not insert due to FK constraint violations. I can’t see where or how the inserted GUIDs are becoming upper cased.

Is it normal for the AUTOID GUID (char(36)) columns to be generated in upper case?

The behavior of the AutoId support for each RDBMS is documented in:

https://docs.servicestack.net/ormlite/reference-support#auto-populated-guid-ids

i.e. since SQLite doesn’t have a native UUID generator it’s populated with Guid.NewGuid().

The AutoQuery Crud docs on Auto Guids shows you can provide custom behavior by using a [AutoPopulate] attribute on your Create DTO instead of [AutoId].

Alternatively to override the default behavior of [AutoId] you can create a custom Dialect Provider with a custom GetInsertDefaultValue() that returns the value you want:

Thanks Demis - I still don’t get why they are upper cased though. They are lower case in the admin-ui profiling of the INSERT statement.

Also RFC 4122 states that the output hex when converted to a string should be in lower case, so I very much doubt the .Net framework is upper casing it.

Am I missing something in your explanation?

Try using a custom SqliteGuidConverter.cs, as the ToQuotedString() on both use upper case.