Entity-Framework-DBZ/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs

25 lines
725 B
C#

using Microsoft.EntityFrameworkCore;
using EntityFrameworkCore.Domain;
namespace EntityFrameworkCore.Data;
public class DeadBallZoneLeagueDbContext : DbContext
{
private string DbPath;
public DeadBallZoneLeagueDbContext()
{
// In Ubuntu 24.04, the file is created here: /home/user/.local/share
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = Path.Combine(path, "DeadBallZoneLeague_EFCore.db");
}
public DbSet<Team> Teams { get; set; }
public DbSet<Coach> Coaches { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data source={DbPath}");
}
}