When the Type is a Nullable Guid then none of the above proposed solutions work.
Invalid cast from 'System.DBNull' to 'System.Guid' exception is thrown at Convert.ChangeType
To fix that change to:
var convertedValue = value == System.DBNull.Value ? null : Convert.ChangeType(value, targetType);