mirror of
https://github.com/XFox111/MuiCharts.git
synced 2026-04-22 06:51:05 +03:00
Added ASP.NET backend with SQLite
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MuiCharts.Domain.Models;
|
||||
using MuiCharts.Infrastructure.Configurations;
|
||||
|
||||
namespace MuiCharts.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the database context for MuiCharts application.
|
||||
/// </summary>
|
||||
public class DataContext : DbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="Point"/> table.
|
||||
/// </summary>
|
||||
public DbSet<Point> Points { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Track"/> table.
|
||||
/// </summary>
|
||||
public DbSet<Track> Tracks { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DataContext() : base() {}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DataContext(DbContextOptions<DataContext> options) : base(options) {}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder
|
||||
.UseSqlite("Data Source=data.db")
|
||||
.EnableSensitiveDataLogging(
|
||||
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development"
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.ApplyConfiguration(new PointEntityTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new TrackEntityTypeConfiguration());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user