richard roeder · Jun 20, 2017

How can I fix it: " 'VARBINARY' is not a supported type for CAST" ?

Hi all,

I trying build a project with .NET and Entity Framework in the Code First method, but Caché return the error " 'VARBINARY' is not a supported type for CAST" when run this sql code:

INSERT "dbo"."__MigrationHistory" 
              cast( 0x1F8B0800000000000400CD59CD6EE33610BE17E83B083A1 ... d89cc74ff4e1285e7df81769242ce52e1f0000 AS varbinary(1549)),


I did all process of this link:


This SQL was generated by Entity Framework.


I'm using Caché 2015.2.5 version


How I fix it?

1 0 3 444
Log in or sign up to continue


Can you execute in SMP:

SELECT cast('0x1F' AS varbinary(1549))

Not sure why


is unescaped though.

It is not clear what it will give.
To Richard need to save the binary data encoded in hex.

For example, instead of '0x2122232425262728292A2F' to the database should persist the value !"#$%&'()*/

USER>w $c(33,34,35,36,37,38,39,40,41,42,47)


USER>zzdump ##class(%xsd.hexBinary).XSDToLogical("2122232425262728292A2F"; 0x omitted
0000: 21 22 23 24 25 26 27 28 29 2A 2F                        !"#$%&'()*/

This command was executed by ODBC connection, and I can not change it.

What I need is to use Caché as the database of a .NET application in the CODE FIRST method.
However, even following the manual I mentioned, Caché is returning error in executing SQL above.