From a8b59a8ca22284056aa3251ce8ad5cb6449d0800 Mon Sep 17 00:00:00 2001 From: Kevin Matsubara Date: Fri, 4 Apr 2025 17:21:16 +0200 Subject: [PATCH] Create DbContext file. --- .../DeadBallZoneLeagueDbContext.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs diff --git a/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs b/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs new file mode 100644 index 0000000..0f8ed04 --- /dev/null +++ b/EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; + +using EntityFrameworkCore.Domain; + +namespace EntityFrameworkCore.Data; + +public class DeadBallZoneLeagueDbContext : DbContext +{ + private string DbPath; + public DeadBallZoneLeagueDbContext() + { + var folder = Environment.SpecialFolder.LocalApplicationData; + var path = Environment.GetFolderPath(folder); + DbPath = Path.Combine(path, "DeadBallZoneLeague_EFCore.db"); + } + public DbSet Teams { get; set; } + public DbSet Coaches { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Data source={DbPath}"); + } +}