Добавил слой Infrastructure
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using UniVerse.Domain.Entities;
|
||||
|
||||
namespace UniVerse.Infrastructure.Data.Configurations;
|
||||
|
||||
public class TeacherProfileConfiguration : IEntityTypeConfiguration<TeacherProfile>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<TeacherProfile> builder)
|
||||
{
|
||||
builder.ToTable("teacher_profiles");
|
||||
|
||||
builder.HasKey(t => t.Id);
|
||||
builder.Property(t => t.Id).HasColumnName("id");
|
||||
builder.Property(t => t.UserId).HasColumnName("user_id");
|
||||
builder.Property(t => t.Department).HasColumnName("department").HasMaxLength(255);
|
||||
builder.Property(t => t.Title).HasColumnName("title").HasMaxLength(255);
|
||||
builder.Property(t => t.Bio).HasColumnName("bio");
|
||||
builder.Property(t => t.ModeusId).HasColumnName("modeus_id").HasMaxLength(255);
|
||||
|
||||
builder.HasOne(t => t.User)
|
||||
.WithOne(u => u.TeacherProfile)
|
||||
.HasForeignKey<TeacherProfile>(t => t.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasIndex(t => t.UserId).IsUnique();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user