File tree 4 files changed +27
-7
lines changed 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -348,3 +348,7 @@ MigrationBackup/
348
348
349
349
# Ionide (cross platform F# VS Code tools) working folder
350
350
.ionide /
351
+
352
+ # Database
353
+ * .db
354
+ * .db- *
Original file line number Diff line number Diff line change 9
9
builder . Services . AddEndpointsApiExplorer ( ) ;
10
10
builder . Services . AddSwaggerGen ( ) ;
11
11
12
- builder . Services . AddDbContext < EntityContext > (
13
- options => options . UseNpgsql ( builder . Configuration . GetConnectionString ( "EntityDb" ) )
14
- ) ;
12
+ String connectionString = Environment . GetEnvironmentVariable ( "DB" ) ;
13
+
14
+ if ( connectionString == "sqlite" ) {
15
+ Console . WriteLine ( $ "Using database connection { connectionString } ") ;
16
+ builder . Services . AddDbContext < EntityContext > (
17
+ options => options . UseSqlite ( builder . Configuration . GetConnectionString ( connectionString ) )
18
+ ) ;
19
+ } else {
20
+ connectionString = "postgres" ;
21
+ Console . WriteLine ( $ "Using database connection { connectionString } ") ;
22
+
23
+ builder . Services . AddDbContext < EntityContext > (
24
+ options => options . UseNpgsql ( builder . Configuration . GetConnectionString ( connectionString ) )
25
+ ) ;
26
+ }
27
+
15
28
16
29
var app = builder . Build ( ) ;
17
30
Original file line number Diff line number Diff line change 6
6
}
7
7
},
8
8
"ConnectionStrings" : {
9
- "EntityDb" : " Server=localhost;Database=entity-framework-example;User Id=user;Password=pass"
9
+ "postgres" : " Server=localhost;Database=entity-framework-example;User Id=user;Password=pass" ,
10
+ "sqlite" : " Data Source=entity.db"
10
11
}
11
12
}
Original file line number Diff line number Diff line change @@ -24,16 +24,18 @@ services:
24
24
restart : unless-stopped
25
25
ports :
26
26
- ${ADMINER_PORT}:8080
27
-
27
+
28
28
sqlitebrowser :
29
29
image : " lscr.io/linuxserver/sqlitebrowser:${SQLITE_BROWSER_TAG}"
30
30
container_name : " ${PROJECT_NAME}-sqlitebrowser"
31
31
security_opt :
32
32
- seccomp:unconfined
33
- ports :
34
- - ${SQLITE_BROWSER_PORT}:3000
35
33
stop_grace_period : 5s
36
34
restart : unless-stopped
35
+ ports :
36
+ - ${SQLITE_BROWSER_PORT}:3000
37
+ volumes :
38
+ - ./EntityFrameworkExample:/app
37
39
38
40
networks :
39
41
default :
You can’t perform that action at this time.
0 commit comments