-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiContext.cs
More file actions
67 lines (61 loc) · 2.15 KB
/
ApiContext.cs
File metadata and controls
67 lines (61 loc) · 2.15 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.EntityFrameworkCore;
using RomRepo.api.Models;
namespace RomRepo.api
{
/// <summary>
/// Database context for the API
/// </summary>
public class ApiContext : DbContext
{
/// <summary>
/// Database table <see cref="ApiKey"/>
/// </summary>
public DbSet<ApiKey> ApiKey { get; set; }
/// <summary>
/// Database table <see cref="GameSystem"/>
/// </summary>
public DbSet<GameSystem> GameSystem { get; set; }
/// <summary>
/// Database table <see cref="Game"/>
/// </summary>
public DbSet<Game> Game { get; set; }
/// <summary>
/// Database table <see cref="Rom"/>
/// </summary>
public DbSet<Rom> Rom { get; set; }
/// <summary>
/// Database table <see cref="GameAttribute"/>
/// </summary>
public DbSet<GameAttribute> GameAttribute { get; set; }
/// <summary>
/// Database table <see cref="GameFavorite"/>
/// </summary>
public DbSet<GameFavorite> GameFavorite { get; set; }
/// <summary>
/// Database table <see cref="GameSystemFavorite"/>
/// </summary>
public DbSet<GameSystemFavorite> GameSystemFavorite { get; set; }
/// <summary>
/// Database table <see cref="GameInstallation"/>
/// </summary>
public DbSet<GameInstallation> GameInstallation { get; set; }
/// <summary>
/// Path to the database file
/// </summary>
public string DbPath { get; }
/// <summary>Constructor</summary>
public ApiContext()
{
//this path code is intended for Docker installation
//DbPath = @"/db_api/romrepo.api.db";
DbPath = "romrepo.api.db";
this.Database.EnsureCreated();
}
/// <summary>
/// Configures the database context to use SQLite
/// </summary>
/// <param name="options"><see cref="DbContextOptionsBuilder"/></param>
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
}
}