I want to use AlwaysEncrypted in a SQL 2016 Standard SP2 server with Entity Framework 6 but my query always fails with this error:
Microsoft.Data.SqlClient.SqlException (0x80131904): Operand type clash: nvarchar(11) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'MyDb') is incompatible with nvarchar Operand type clash: nvarchar(11) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'MyDb') is incompatible with nvarchar
My database collation is Latin1_General_CI_AS_KS_WS which is not compatible with AlwaysEncrypted because it needs _BIN2. I have chaned the problemtaic column collation to Latin1_General_BIN2 but it doesn't work.
UPDATE I'm sorry but I forgot to mentiop that I use stored procedure for querying the from database. :| It returns a filtered row set and the total number of filtered records.
UPDATE2
The problem is not my stored procedure but the filter on the nvarchar column. When I run my select without filter is Ok, but when I put this filter ( where EncryptedColumn like N'111 222 333 444') on the encrypted column it gives this error:
Operand type clash: nvarchar(11) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'MyDb') is incompatible with nvarchar
And if I change the 'LIKE' operator to an equal operator it returns with this: ... and nvarchar are incompatible in the equal to operator.
using a procedure, that's like saying:i'm driving a volvowhen the mechanic is asking you for details on what's wrong with your car, just post the gist of y our query