Skip to content
Snippets Groups Projects
Select Git revision
  • 50a067f912aef77406ec958e5e9a91d3e3087b75
  • master default
  • develop
  • feature/modify-course-sections
  • videoConferencePOC
5 results

CourseConfiguration.cs

Blame
  • CourseConfiguration.cs 1.08 KiB
    using Microsoft.EntityFrameworkCore;
    using Microsoft.EntityFrameworkCore.Metadata.Builders;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Tsi1.DataLayer.Entities;
    
    namespace Tsi1.DataLayer.EntityConfiguration
    {
        public class CourseConfiguration : IEntityTypeConfiguration<Course>
        {
            public void Configure(EntityTypeBuilder<Course> builder)
            {
                builder.HasKey(x => x.Id);
    
                builder.HasIndex(x => new { x.Name, x.TenantId })
                    .IsUnique();
    
                builder.Property(x => x.Name)
                    .IsRequired()
                    .HasColumnType("character varying(50)");
    
                builder.Property(x => x.IsTemplate)
                    .IsRequired();
    
                builder.Property(x => x.HasPassword)
                    .IsRequired();
    
                builder.Property(x => x.Password)
                    .IsRequired()
                    .HasColumnType("character varying(200)");
    
                builder.HasOne(x => x.Tenant)
                    .WithMany(x => x.Courses)
                    .HasForeignKey(x => x.TenantId);
            }
        }
    }