Open uenlkr4e opened 4 months ago
anyone? i really want to use this package.
Had the same problem when i tried to save my model to the database.
First thing i had to change is the example_encrypt_key
value in the GenerateEncryptionProvider. I changed this to AAECAwQFBgcICQoLDA0ODw==
.
Second thing is that i had to downgrade my entityframeworkcore nuget package version to 6.0.0 (Also for the .Design, .Tools and .SqlServer).
Third. i see you use a partial modelcreating OnModelCreatingPartial
method, but not provided what it contains. Maybe that could also contain a issue.
Lastly. Saving data directly to the database with an insert does not encrypt / decrypt the data with the [EncryptColumn]
attribute. i had to CRUD the model via the dbcontext class.
Try this for example:
AppDbContext dbContext = new();
YOURMODEL model = new()
{
UserName = "uenlkr4e",
FirstName = "Shane",
Email = "Shane@gmail.com"
};
dbContext.YOURDBSET.Add(model);
dbcontext.SaveChanges()
You only have the change the YOURMODEL
to the model of the data and YOURDBSET
to your dbset
If you still have issue's, let me know ;)
I ended up using EntityFrameworkCore.JamieEncryptColumn from nuget. Appears to be a fork off this project but not 100% sure, but seems to work well with EF 8.x
I ended up using EntityFrameworkCore.JamieEncryptColumn from nuget. Appears to be a fork off this project but not 100% sure, but seems to work well with EF 8.x
Yeah, it is the same project, but with the use of newer packages versions for EntityFrameworkCore 8.0.0 and above.
So i will use this instead. Thanks for the tip :D
Hi, i am using .NET 7 and i did exactly what you described in documentation but nothing happens, my data is still saved in clear text. Am i missing something?
here is my dbcontext:
private readonly IEncryptionProvider _provider; public AppDbContext() { _provider = new GenerateEncryptionProvider("example_encrypt_key"); } ..... protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.UseEncryption(_provider); modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
and my entity model: [EncryptColumn] public string UserName { get; set; }