Add a Persistence layer #3
35
Persistence/UberDbContext.cs
Normal file
35
Persistence/UberDbContext.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mirea.Api.DataAccess.Domain.Schedule;
|
||||||
|
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations.Schedule;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Persistence;
|
||||||
|
|
||||||
|
public class UberDbContext(DbContextOptions<UberDbContext> options) : DbContext(options)
|
||||||
|
{
|
||||||
|
public DbSet<Day> Days { get; set; } = null!;
|
||||||
|
public DbSet<Group> Groups { get; set; } = null!;
|
||||||
|
public DbSet<LectureHall> LectureHalls { get; set; } = null!;
|
||||||
|
public DbSet<Lesson> Lessons { get; set; } = null!;
|
||||||
|
public DbSet<Professor> Professors { get; set; } = null!;
|
||||||
|
public DbSet<TypeOfOccupation> TypeOfOccupations { get; set; } = null!;
|
||||||
|
public DbSet<Faculty> Faculties { get; set; } = null!;
|
||||||
|
public DbSet<Campus> Campuses { get; set; } = null!;
|
||||||
|
public DbSet<ProfessorToLesson> ProfessorToLessons { get; set; } = null!;
|
||||||
|
public DbSet<LessonToTypeOfOccupation> LessonToTypeOfOccupations { get; set; } = null!;
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.ApplyConfiguration(new DayConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new GroupConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new LectureHallConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new LessonConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new ProfessorConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new TypeOfOccupationConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new FacultyConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new CampusConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new ProfessorToLessonConfiguration());
|
||||||
|
modelBuilder.ApplyConfiguration(new LessonToTypeOfOccupationConfiguration());
|
||||||
|
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user