23 lines
730 B
C#
23 lines
730 B
C#
using Api.Database.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Api.Database;
|
|
|
|
public class SanStudentContext : DbContext
|
|
{
|
|
public SanStudentContext(DbContextOptions<SanStudentContext> options) : base(options) { }
|
|
|
|
public required virtual DbSet<Specialization> Specializations { get; set; }
|
|
public required virtual DbSet<Subject> Subjects { get; set; }
|
|
public virtual required DbSet<Season> Seasons { get; set; }
|
|
public required virtual DbSet<Student> Students { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Student>(entity =>
|
|
{
|
|
entity.HasIndex(e => e.AlbumNumber).IsUnique();
|
|
});
|
|
}
|
|
}
|