| | | 1 | | using Syki.Back.Domain.Campi; |
| | | 2 | | using Syki.Back.Domain.Identity; |
| | | 3 | | using Syki.Back.Domain.Teachers; |
| | | 4 | | using Syki.Back.Domain.Disciplines; |
| | | 5 | | |
| | | 6 | | namespace Syki.Back.Database.Teachers; |
| | | 7 | | |
| | | 8 | | public class SykiTeacherDbConfig : IEntityTypeConfiguration<SykiTeacher> |
| | | 9 | | { |
| | | 10 | | public void Configure(EntityTypeBuilder<SykiTeacher> entity) |
| | | 11 | | { |
| | 4 | 12 | | entity.ToTable("teachers", DbSchemas.Syki); |
| | | 13 | | |
| | 4 | 14 | | entity.HasKey(e => e.Id); |
| | | 15 | | |
| | 4 | 16 | | entity.HasOne(e => e.User) |
| | 4 | 17 | | .WithOne() |
| | 4 | 18 | | .HasPrincipalKey<SykiUser>(u => new { u.InstitutionId, u.Id }) |
| | 4 | 19 | | .HasForeignKey<SykiTeacher>(e => new { e.InstitutionId, e.UserId }); |
| | | 20 | | |
| | 4 | 21 | | entity.HasMany(c => c.Campi) |
| | 4 | 22 | | .WithMany() |
| | 4 | 23 | | .UsingEntity<TeacherCampus>( |
| | 4 | 24 | | right => right.HasOne<Campus>().WithMany().HasForeignKey(tc => tc.CampusId), |
| | 4 | 25 | | left => left.HasOne<SykiTeacher>().WithMany().HasForeignKey(tc => tc.TeacherId) |
| | 4 | 26 | | ); |
| | | 27 | | |
| | 4 | 28 | | entity.HasMany(e => e.Disciplines) |
| | 4 | 29 | | .WithMany() |
| | 4 | 30 | | .UsingEntity<TeacherDiscipline>( |
| | 4 | 31 | | right => right.HasOne<Discipline>().WithMany().HasForeignKey(td => td.DisciplineId), |
| | 4 | 32 | | left => left.HasOne<SykiTeacher>().WithMany().HasForeignKey(td => td.TeacherId) |
| | 4 | 33 | | ); |
| | 4 | 34 | | } |
| | | 35 | | } |