EntityFrameworkCore.DataEncryption icon indicating copy to clipboard operation
EntityFrameworkCore.DataEncryption copied to clipboard

This package is a plugin that adds data encryption support to EF Core.

Gitmoji


Give a Star 🌟

If you liked the project or if EntityFrameworkCore.DataEncryption helped you, please give a star.


Purpose

EntityFrameworkCore.DataEncryption with the entity framework core value converter feature, it allows you to store your data by encrypting it.


Summary

Install-Package EntityFrameworkCore.DataEncryption.Conversions

Then mark the columns to be encrypted in DbContext.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Author>(entity =>
    {
        entity
            .Property(p => p.Id)
            .UseIdentityColumn();
        entity
            .Property(p => p.Name)
            .IsRequired()
            .HasMaxLength(2048);
        
        entity
            .Property(p => p.Surname)
            .IsRequired()
            .HasMaxLength(2048);
        entity
            .Property(p => p.Phone)
            .IsRequired()
            .HasConversion(new EncryptValueConverter(key:"89acMXSBpuEBDWHZ"));
    });
    base.OnModelCreating(modelBuilder);
}

Documentation

Visit wiki documentation. Wiki


Sample Project

See for more information visit sample project