Create DbContext file.
This commit is contained in:
parent
f58f92d0e0
commit
a8b59a8ca2
23
EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs
Normal file
23
EntityFrameworkCore.Data/DeadBallZoneLeagueDbContext.cs
Normal file
@ -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<Team> Teams { get; set; }
|
||||
public DbSet<Coach> Coaches { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseSqlite($"Data source={DbPath}");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user