我有一个 Windows 窗体应用程序,它已经按原样运行了很长时间,现在我必须加密/解密数据库中的某些列。我对数据库进行了所有配置,将列配置为加密,将列的数据类型从 varchar(max)
更改为 nvarchar(max)
,在 Windows 商店中创建了证书,为客户端导出了证书,现在我正在尝试在客户端完成这项工作。
我将 Windows 窗体应用程序框架更改为 4.6,将 Column Encryption Setting=enabled
添加到我的连接字符串,更新了 .dbml
设计器,但当我仍然收到以下错误时尝试插入一个值:
Operand type clash: varchar(8000) 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 = 'MCM_V2') collation_name = 'Greek_CI_AS' is incompatible with varchar(50) 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') collation_name = 'Greek_BIN2'
我使用 Linq 进行查询
最佳答案
您似乎正在使用非 BIN2 排序规则。始终加密当前仅支持 BIN2 排序规则。
Always Encrypted is not supported for the columns with the below characteristics (e.g. the Encrypted WITH clause cannot be used in CREATE TABLE/ALTER TABLE for a column, if any of the following conditions apply to the column):
...
String (varchar, char, etc.) columns with non-bin2 collations
关于c# - SQL Server 始终在插入时加密排序规则不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46834951/