-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.cs
More file actions
46 lines (42 loc) · 2.36 KB
/
db.cs
File metadata and controls
46 lines (42 loc) · 2.36 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
using api.Models;
using Microsoft.EntityFrameworkCore;
namespace api
{
public class Db(DbContextOptions<Db> options) : DbContext(options)
{
public static string GetLocalDbConnection(WebApplicationBuilder builder) =>
$"Data Source={builder.Configuration.GetValue<string>("Local_Db_Path")}" +
$"{builder.Configuration.GetValue<string>("Local_Db_File")};";
public static string GetProductionDbConnetion(WebApplicationBuilder builder) =>
$"USER ID={builder.Configuration.GetValue<string>("Postgres_User") ?? "postgres"};" +
$"Password={builder.Configuration.GetValue<string>("Postgres_Password") ?? "postgres"};" +
$"Server={builder.Configuration.GetValue<string>("Postgres") ?? "localhost"};" +
$"Port={builder.Configuration.GetValue<string>("Postgres_Port") ?? "5432"};" +
$"Database={builder.Configuration.GetValue<string>("Postgres_Db") ?? "dnd"};" +
$"Integrated Security=true;" +
$"Pooling=true;";
public DbSet<Spell> Spells { get; set; }
public DbSet<School> Schools { get; set; }
public DbSet<Class> Classes { get; set; }
public DbSet<Condition> Conditions { get; set; }
public DbSet<SpellTag> SpellTags { get; set; }
public DbSet<Feature> Features { get; set; }
public DbSet<Feat> Feats { get; set; }
public DbSet<Rule> Rules { get; set; }
public DbSet<Character> Characters { get; set; }
public DbSet<CharacterAttributes> CharacterAttributes { get; set; }
public DbSet<CharacterExpert> CharacterExperts { get; set; }
public DbSet<CharacterHitpoint> CharacterHitpoints { get; set; }
public DbSet<CharacterSpellCasting> CharacterSpellCastings { get; set; }
public DbSet<CharacterExtra> CharacterExtras { get; set; }
public DbSet<Item> Items { get; set; }
public DbSet<CharacterSpell> CharacterSpells { get; set; }
public DbSet<CharacterAttack> CharacterAttacks { get; set; }
public DbSet<CharacterItem> CharacterItems { get; set; }
public DbSet<ItemEffect> ItemEffects { get; set; }
public DbSet<Race> Races { get; set; }
public DbSet<Background> Backgrounds { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) =>
modelBuilder.UseIdentityAlwaysColumns();
}
}