You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.9 KiB
86 lines
2.9 KiB
//-----------------------------------------------------------------------
|
|
// FILENAME: LibraryContext.cs
|
|
// PROJECT: DbContextLib
|
|
// SOLUTION: FitnessApp
|
|
// DATE CREATED: 22/02/2024
|
|
// AUTHOR: Antoine PEREDERII
|
|
//-----------------------------------------------------------------------
|
|
|
|
using Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace DbContextLib
|
|
{
|
|
/// <summary>
|
|
/// Represents the database context for the FitnessApp.
|
|
/// </summary>
|
|
public class LibraryContext : DbContext
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the set of athletes.
|
|
/// </summary>
|
|
public DbSet<AthleteEntity> AthletesSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of activities.
|
|
/// </summary>
|
|
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of data sources.
|
|
/// </summary>
|
|
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of heart rates.
|
|
/// </summary>
|
|
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of notifications.
|
|
/// </summary>
|
|
public DbSet<NotificationEntity> NotificationsSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of statistics.
|
|
/// </summary>
|
|
public DbSet<StatisticEntity> StatisticsSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of trainings.
|
|
/// </summary>
|
|
public DbSet<TrainingEntity> TrainingsSet { get; set; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LibraryContext"/> class.
|
|
/// </summary>
|
|
public LibraryContext() : base() { }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LibraryContext"/> class with the specified options.
|
|
/// </summary>
|
|
/// <param name="options">The options for the context.</param>
|
|
public LibraryContext(DbContextOptions<LibraryContext> options) : base(options) { }
|
|
|
|
/// <summary>
|
|
/// Configures the database options if they are not already configured.
|
|
/// </summary>
|
|
/// <param name="optionsBuilder">The options builder instance.</param>
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configures the model for the library context.
|
|
/// </summary>
|
|
/// <param name="modelBuilder">The model builder instance.</param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
}
|
|
} |