Search code examples
sql-serverentity-framework-coreazure-sql-database

Is there a way to encrypt a column in SQL Server?


Yes I can do the encryption myself. But is there a way to tell SQL Server (and Azure SQL Database) to encrypt a column and it then handles encrypting it on a save and decrypting it on a read?

This is for a column that is not indexed and will never be part of a where clause. I use Entity Framework Core hitting SQL Server (on our dev systems) and Azure SQL Database on our QA and production systems.


Solution

  • SQL Server supports transparent client-side column encryption with Always Encrypted.

    You can also use EF Value Conversions to store data in a column in a format different than it appears in the entity. So you could have an encrypted varbinary column in SQL Server and a decrypted string in C#.