-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleDbContext.cs
More file actions
34 lines (27 loc) · 968 Bytes
/
Copy pathSampleDbContext.cs
File metadata and controls
34 lines (27 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using EfCore.EncryptedProperties.Extensions;
using Microsoft.EntityFrameworkCore;
namespace EfCore.EncryptedProperties.Samples.AzuriteBlobs;
public sealed class SampleDbContext : DbContext
{
public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { }
public DbSet<Customer> Customers => Set<Customer>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.Email)
.IsEncrypted();
entity.Property(e => e.SecretNotes)
.IsEncrypted(options =>
{
options.KeyPurpose = "notes";
});
entity.Property(e => e.LoyaltyPoints)
.IsEncrypted(options =>
{
options.KeyPurpose = "loyalty";
});
});
}
}