Error loading guid NULL-value (MS SQL)

Asking you help with next error, while loading record from MS SQL:

dotnet: fail: Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'Lic.Data.AppLicContext'.
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
at Microsoft.Data.SqlClient.SqlBuffer.ThrowIfNull()
at Microsoft.Data.SqlClient.SqlBuffer.get_Guid()
at Microsoft.Data.SqlClient.SqlDataReader.GetGuid(Int32 i)
at lambda_method(Closure , QueryContext , DbDataReader , ResultContext , Int32 , ResultCoordinator )
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()

My guess is: Radzen doesn't expect NULL value in column with GUID (uniqueidentifier) type.
Is that right?

I've found a recommendation from MS to add NULL-check for function like GetGuid, m. b. this would be a solution for future releases?

In Remarks section:
Call IsDBNull to check for null values before calling this method.

Thank you!

Most probably nullable field is wrongly mapped to non nullable property. Can you check the property definition and the database definition?

All properties are generated by Radzen while creating "DataGrid with Form" page, no manual changes.

DB table fields (AD_guid is nullable)


Data in table


Properties of auto-generated form field for AD_guid

As far as i understand, this question mark (?) means field can be NULL

If this helps:
Error strikes when trying to open a page (page just not opens)
i.e. first record is loading into the form

Here is page Load event code, just in case (also auto-generated, no manual changes)


Will you post the property definition in c# model?

Is that file correct?

Sorry, not too familiar with programming. If file is wrong - give a clue please :slight_smile:

Everything looks correct, I’m not sure why you get this exception.

App working great after changing GUID to a value
With NULL in GUID - exception is back

Sadly, in this table GUIDs can be unknown, and then are set to NULL


Sorry for asking - is exception reproduced by you?
Looks like there is need for additional check for NULL on retrieving values from GUID-type columns...