sa/Stars Assistant/Model/StarsDatabase.cs

43 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace StarsAssistant.Model;
public class StarsDatabase(string DbPath) : DbContext
{
#region Configuration and Construction
public string DbPath { get; } = DbPath;
/// <summary>
/// Configure for SQLite and set the DB Path given.
/// </summary>
/// <param name="options">Options to update</param>
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
#endregion
#region IStarsDatabase Implementation
public DbContext DbContext => this;
/// <summary>
/// List of all Planets read.
/// </summary>
public DbSet<Planet> Planet { get; set; }
/// <summary>
/// Lists of all defined races.
/// </summary>
public DbSet<Race> Race { get; set; }
/// <summary>
/// The record with all game metadata, will only contain a single line at all times.
/// </summary>
public DbSet<Game> Game { get; set; }
#endregion
}