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" 
       ( 
              "MigrationId", 
              "ContextKey", 
              "Model", 
              "ProductVersion" 
       ) 
       VALUES 
       ( 
              '201706131048154_InitialCreate', 
              'CACHE2.SchoolContext', 
              cast( 0x1F8B0800000000000400CD59CD6EE33610BE17E83B083A1 ... d89cc74ff4e1285e7df81769242ce52e1f0000 AS varbinary(1549)),
              '6.1.3-40302' 
       )

 

I did all process of this link: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GBMP_eframe#GBMP_eframe_codefirst.

 

This SQL was generated by Entity Framework.

 

I'm using Caché 2015.2.5 version

 

How I fix it?

  • 0
  • 0
  • 326
  • 3
  • 0

Comments

Can you execute in SMP:

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

Not sure why

0x1F8B08000000...

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>##class(%xsd.hexBinary).LogicalToXSD($c(33,34,35,36,37,38,39,40,41,42,47))
2122232425262728292A2F

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.