AltairCA.EntityFrameworkCore.PomeloMysql.Extensions 6.0.0

dotnet add package AltairCA.EntityFrameworkCore.PomeloMysql.Extensions --version 6.0.0
NuGet\Install-Package AltairCA.EntityFrameworkCore.PomeloMysql.Extensions -Version 6.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AltairCA.EntityFrameworkCore.PomeloMysql.Extensions" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AltairCA.EntityFrameworkCore.PomeloMysql.Extensions --version 6.0.0
#r "nuget: AltairCA.EntityFrameworkCore.PomeloMysql.Extensions, 6.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AltairCA.EntityFrameworkCore.PomeloMysql.Extensions as a Cake Addin
#addin nuget:?package=AltairCA.EntityFrameworkCore.PomeloMysql.Extensions&version=6.0.0

// Install AltairCA.EntityFrameworkCore.PomeloMysql.Extensions as a Cake Tool
#tool nuget:?package=AltairCA.EntityFrameworkCore.PomeloMysql.Extensions&version=6.0.0

AltairCA.EntityFrameworkCore.PomeloMysql.Extensions

Build Status

AltairCA.EntityFrameworkCore.PomeloMysql.Extensions is a Pomelo Mysql Extension that supports native MySQL AES encryption. Meaning this will support search query on encrypted columns. Well, this is good if you have GDPR compliance requirement.

Note

If you use this make sure your application to the MySQL service is use a encrypted connection because this will transmit the RAW PASSWORD over the network. You can enforce it in the connection string. example -

{
  "DefaultConnection": "server=127.0.0.1;database=youdb;user=root;password=;persistsecurityinfo=True;port=3306;SslMode=Required;CharSet=utf8mb4;"
}

take a look at SslMode=Required

AltairCA.EntityFrameworkCore.PomeloMysql.Extensions targets netstandard2.0. The package has following dependencies

<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />

When you choose the version choose with the .Net Core Version for example if .Net Core version is 6.0 then choose AltairCA.EntityFrameworkCore.PomeloMysql.Extensions version 6.0.x

setup

NuGet install:

Install-Package AltairCA.EntityFrameworkCore.PomeloMysql.Extensions

DbContext

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseEncryptionFunctions("HelloWorld1");
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
            builder.UseEncryptAttribute("HelloWorld1");
        }

Replace HelloWorld with your password

Example of use

MysqlEncrypt Annotation Use
    public class TestModel
    {
        public string Id { get; set; } = Guid.NewGuid().ToString();
        [MysqlEncrypt] #Use MysqlEncrypt attribute to denote the property must be encrypt in database
        public string Name { get; set; }
    }
How to use it in search query
var searchTest = _dbContext.TModels.Where(x => x.Name.MySqlDecrypt().Contains("test")).ToList();

Above Linq will convert to a Native MySql Query that will decrypt the column before it do a search.

You can find a example that I have used in the WebApplication Project HomeController.cs

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.0 1,719 4/14/2022
3.1.2 1,935 4/28/2020
3.1.1 447 4/26/2020