Add project
This commit is contained in:
12
Api/Database/Entities/BaseEntity.cs
Normal file
12
Api/Database/Entities/BaseEntity.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
[Key]
|
||||
[Column("Id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
18
Api/Database/Entities/BaseEntityGuid.cs
Normal file
18
Api/Database/Entities/BaseEntityGuid.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
public abstract class BaseEntityGuid
|
||||
{
|
||||
[Key]
|
||||
[Column("Id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; } = Guid.CreateVersion7();
|
||||
|
||||
[Column("CreatedAt")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
|
||||
[Column("LastModifiedAt")]
|
||||
public DateTime LastModifiedAt { get; set; } = DateTime.Now;
|
||||
}
|
||||
22
Api/Database/Entities/Season.cs
Normal file
22
Api/Database/Entities/Season.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
[Table("Seasons")]
|
||||
public class Season : BaseEntity
|
||||
{
|
||||
[Column("Name")]
|
||||
[NotNull]
|
||||
[MaxLength(20)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("StartDate")]
|
||||
[NotNull]
|
||||
public DateOnly StartDate { get; set; }
|
||||
|
||||
[Column("EndDate")]
|
||||
[NotNull]
|
||||
public DateOnly EndDate { get; set; }
|
||||
}
|
||||
19
Api/Database/Entities/Specialization.cs
Normal file
19
Api/Database/Entities/Specialization.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
[Table("Specializations")]
|
||||
public class Specialization : BaseEntity
|
||||
{
|
||||
[Column("Name")]
|
||||
[NotNull]
|
||||
[MaxLength(200)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("ShortName")]
|
||||
[NotNull]
|
||||
[MaxLength(10)]
|
||||
public string? ShortName { get; set; }
|
||||
}
|
||||
24
Api/Database/Entities/Student.cs
Normal file
24
Api/Database/Entities/Student.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
[Table("Students")]
|
||||
public class Student : BaseEntityGuid
|
||||
{
|
||||
[Column("FirstName")]
|
||||
[NotNull]
|
||||
[MaxLength(50)]
|
||||
public string? FirstName { get; set; }
|
||||
|
||||
[Column("LastName")]
|
||||
[NotNull]
|
||||
[MaxLength(50)]
|
||||
public string? LastName { get; set; }
|
||||
|
||||
[Column("AlbumNumber")]
|
||||
[NotNull]
|
||||
[MaxLength(6)]
|
||||
public string? AlbumNumber { get; set; }
|
||||
}
|
||||
19
Api/Database/Entities/Subject.cs
Normal file
19
Api/Database/Entities/Subject.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Api.Database.Entities;
|
||||
|
||||
[Table("Subjects")]
|
||||
public class Subject : BaseEntity
|
||||
{
|
||||
[Column("Name")]
|
||||
[NotNull]
|
||||
[MaxLength(200)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("ShortName")]
|
||||
[NotNull]
|
||||
[MaxLength(10)]
|
||||
public string? ShortName { get; set; }
|
||||
}
|
||||
70
Api/Database/Migrations/20260301222003_CreateDb.Designer.cs
generated
Normal file
70
Api/Database/Migrations/20260301222003_CreateDb.Designer.cs
generated
Normal file
@@ -0,0 +1,70 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Api.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Api.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(SanStudentContext))]
|
||||
[Migration("20260301222003_CreateDb")]
|
||||
partial class CreateDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("AlbumNumber")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("nvarchar(6)")
|
||||
.HasColumnName("AlbumNumber");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("CreatedAt");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("FirstName");
|
||||
|
||||
b.Property<DateTime>("LastModifiedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("LastModifiedAt");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("LastName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AlbumNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Api/Database/Migrations/20260301222003_CreateDb.cs
Normal file
44
Api/Database/Migrations/20260301222003_CreateDb.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Api.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class CreateDb : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Students",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
FirstName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
LastName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
AlbumNumber = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Students", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Students_AlbumNumber",
|
||||
table: "Students",
|
||||
column: "AlbumNumber",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Students");
|
||||
}
|
||||
}
|
||||
}
|
||||
150
Api/Database/Migrations/20260305195643_SpecsSubjectsAndSeasons.Designer.cs
generated
Normal file
150
Api/Database/Migrations/20260305195643_SpecsSubjectsAndSeasons.Designer.cs
generated
Normal file
@@ -0,0 +1,150 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Api.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Api.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(SanStudentContext))]
|
||||
[Migration("20260305195643_SpecsSubjectsAndSeasons")]
|
||||
partial class SpecsSubjectsAndSeasons
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Season", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("EndDate");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("StartDate");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Seasons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Specialization", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)")
|
||||
.HasColumnName("ShortName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Specializations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("AlbumNumber")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("nvarchar(6)")
|
||||
.HasColumnName("AlbumNumber");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("CreatedAt");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("FirstName");
|
||||
|
||||
b.Property<DateTime>("LastModifiedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("LastModifiedAt");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("LastName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AlbumNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Subject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)")
|
||||
.HasColumnName("ShortName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Subjects");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Api.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SpecsSubjectsAndSeasons : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Seasons",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
||||
StartDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
EndDate = table.Column<DateOnly>(type: "date", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Seasons", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Specializations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
ShortName = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Specializations", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Subjects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
ShortName = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Subjects", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Seasons");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Specializations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Subjects");
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Api/Database/Migrations/SanStudentContextModelSnapshot.cs
Normal file
147
Api/Database/Migrations/SanStudentContextModelSnapshot.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Api.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Api.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(SanStudentContext))]
|
||||
partial class SanStudentContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Season", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("EndDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("EndDate");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("StartDate");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Seasons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Specialization", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)")
|
||||
.HasColumnName("ShortName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Specializations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Student", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("AlbumNumber")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("nvarchar(6)")
|
||||
.HasColumnName("AlbumNumber");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("CreatedAt");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("FirstName");
|
||||
|
||||
b.Property<DateTime>("LastModifiedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("LastModifiedAt");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("LastName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AlbumNumber")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Api.Database.Entities.Subject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("Id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("ShortName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)")
|
||||
.HasColumnName("ShortName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Subjects");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Api/Database/SanStudentContext.cs
Normal file
22
Api/Database/SanStudentContext.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user