I've created a database-first EDM for a table with columns encrypted using Always Encrypted. Our business prohibits direct access to tables, so I'm also using stored procedures for all database access.
When I try to insert row, I get the following error:
System.Data.SqlClient.SqlException: Operand type clash: varchar(8000) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'XXXXXX', column_encryption_key_database_name = 'XXXXXX') collation_name = 'SQL_Latin1_General_CP1_CI_AS' is incompatible with varchar(60) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'XXXXXX', column_encryption_key_database_name = 'XXXXXX') collation_name = 'SQL_Latin1_General_CP1_CI_AS
The stored procedure parameter is declared as varchar(60) which matches the table definition.
Because I'm using Always Encrypted, the parameter definition must match the column definition. However, EF generates a parameter declared as varchar(8000) for this property, which violates the encryption contract.
Is there any way to force EF to use the declared parameter length?