Eastrall / EntityFrameworkCore.DataEncryption

A plugin for Microsoft.EntityFrameworkCore to add support of encrypted fields using built-in or custom encryption providers.
MIT License
326 stars 54 forks source link

Migration on plaintext database properties error #32

Closed isIulian closed 9 months ago

isIulian commented 2 years ago

I have an existing database table that I have decided to encrypt and I have configured an MirgrationEncryptionProvider so it will map the previous data

 var migrationProvider = new MigrationEncryptionProvider(null,  new AesProvider(encryptionKey, encryptionIV));
_encryptionProvider = migrationProvider;

and now I'm calling the migration procedure when needed await _db.MigrateAsync(); so it take all properties decorated with EcryptionAttribute and applies the mapping from previous encryption to the new one. There is a problem for default case, the plaintext columns. The error is caused by the default decoder for string types in my cases. Knowing the it isn't encoded it should return the value that is stored on database, not to try to decode it with FromBase64String decoder that we pass.

FormatException The format of s is invalid. s contains a non-base-64 character, more than two padding characters, or a non-white space-character among the padding characters.

Note: It work very well to pass from and ecrypted version to another one, it only the plaintext case, that is a problem in my opinion.

Eastrall commented 2 years ago

Hello, thank you for openning an issue regarding the migrator. I will look into it.

Eastrall commented 9 months ago

Migrator has been removed from the library since 3.X. Closing issue.