File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
sample/EntityFrameworkCore.DataEncryption.Sample/Context Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ using EntityFrameworkCore . DataEncryption . Conversions ;
2+ using EntityFrameworkCore . DataEncryption . Sample . Entities ;
3+ using Microsoft . EntityFrameworkCore ;
4+
5+ namespace EntityFrameworkCore . DataEncryption . Sample . Context ;
6+
7+ /// <summary>
8+ /// Sample Db Context
9+ /// </summary>
10+ public class SampleDbContext : DbContext
11+ {
12+ /// <summary>
13+ /// protected ctor
14+ /// </summary>
15+ protected SampleDbContext ( )
16+ {
17+ }
18+
19+ /// <summary>
20+ /// public ctor
21+ /// </summary>
22+ /// <param name="options">
23+ /// DbContext Options object. <see cref="DbContextOptions{TContext}"/>
24+ /// </param>
25+ public SampleDbContext ( DbContextOptions options ) : base ( options )
26+ {
27+ }
28+
29+ public virtual DbSet < Author > Authors { get ; set ; }
30+
31+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
32+ {
33+ modelBuilder . Entity < Author > ( entity =>
34+ {
35+ entity
36+ . Property ( p => p . Id )
37+ . UseIdentityColumn ( ) ;
38+
39+ entity
40+ . Property ( p => p . Name )
41+ . IsRequired ( )
42+ . HasMaxLength ( 2048 ) ;
43+
44+ entity
45+ . Property ( p => p . Surname )
46+ . IsRequired ( )
47+ . HasMaxLength ( 2048 ) ;
48+
49+ entity
50+ . Property ( p => p . Phone )
51+ . IsRequired ( )
52+ . HasConversion ( new EncryptValueConverter ( "89acMXSBpuEBDWHZ" ) ) ;
53+ } ) ;
54+ base . OnModelCreating ( modelBuilder ) ;
55+ }
56+ }
You can’t perform that action at this time.
0 commit comments