Transparent column-level encryption for Entity Framework Core with Azure Key Vault and HashiCorp Vault support.
License
—
Deps
7
Install Size
—
Vulns
✓ 0
Published
Feb 7, 2026
$ dotnet add package Tricksfor.ColumnEncryptorTransparent column-level encryption for Entity Framework Core with Azure Key Vault and HashiCorp Vault support.
dotnet add package Tricksfor.ColumnEncryptor
1. Configure services:
services.AddColumnEncryption(options =>
{
options.KeyProvider = KeyProviderType.AzureKeyVault;
options.AzureKeyVault = new AzureKeyVaultOptions
{
VaultUrl = "https://your-keyvault.vault.azure.net/",
AuthMethod = AzureAuthMethod.DefaultAzureCredential
};
});
await app.Services.InitializeEncryptionKeysAsync();
2. Mark properties:
public class User
{
public int Id { get; set; }
[Encrypted]
public string Email { get; set; } = string.Empty;
}
3. Configure DbContext:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseColumnEncryption(_encryptionService);
}
public override async Task<int> SaveChangesAsync(CancellationToken ct = default)
{
this.ProcessEncryption(_encryptionService);
return await base.SaveChangesAsync(ct);
}
MIT License - see LICENSE