// This file has been auto generated by EF Core Power Tools. #nullable enable using System; using System.Collections.Generic; using EF_Demo.Models; using Microsoft.EntityFrameworkCore; namespace EF_Demo.Data.MSSQL; public partial class EventsContext : DbContext { public EventsContext(DbContextOptions options) : base(options) { } public virtual DbSet Countries { get; set; } public virtual DbSet Events { get; set; } public virtual DbSet People { get; set; } public virtual DbSet Registrations { get; set; } public virtual DbSet Sports { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => e.Code); entity.ToTable("Country"); entity.HasIndex(e => e.Name, "UQ_Country_Name").IsUnique(); entity.Property(e => e.Code) .HasMaxLength(3) .IsUnicode(false); entity.Property(e => e.Alpha3) .HasMaxLength(3) .IsUnicode(false) .IsFixedLength(); entity.Property(e => e.Name) .HasMaxLength(100) .IsUnicode(false); }); modelBuilder.Entity(entity => { entity.ToTable("Event"); entity.Property(e => e.Name) .HasMaxLength(150) .IsUnicode(false); }); modelBuilder.Entity(entity => { entity.ToTable("Person"); entity.HasIndex(e => new { e.DocumentNumber, e.CountryCode }, "UQ_Person_DocumentNumber_CountryCode").IsUnique(); entity.Property(e => e.AddressCountry) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.AddressLine) .HasMaxLength(200) .IsUnicode(false); entity.Property(e => e.City) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.ContactPhone) .HasMaxLength(50) .IsUnicode(false); entity.Property(e => e.CountryCode) .HasMaxLength(3) .IsUnicode(false); entity.Property(e => e.DocumentNumber) .HasMaxLength(50) .IsUnicode(false); entity.Property(e => e.Email) .HasMaxLength(255) .IsUnicode(false); entity.Property(e => e.FirstName) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.FirstNameTranscription) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.LastName) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.LastNameTranscription) .HasMaxLength(100) .IsUnicode(false); entity.Property(e => e.PostalCode) .HasMaxLength(20) .IsUnicode(false); entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.People) .HasForeignKey(d => d.CountryCode) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("FK_Person_Country"); }); modelBuilder.Entity(entity => { entity.ToTable("Registration"); entity.HasIndex(e => new { e.PersonId, e.SportId, e.EventId }, "UQ_Registration_PersonId_SportId_EventId").IsUnique(); entity.Property(e => e.RegisteredAt).HasDefaultValueSql("(sysdatetime())", "DF_Registration_RegisteredAt"); entity.HasOne(d => d.Event).WithMany(p => p.Registrations) .HasForeignKey(d => d.EventId) .HasConstraintName("FK_Registration_Event"); entity.HasOne(d => d.Person).WithMany(p => p.Registrations) .HasForeignKey(d => d.PersonId) .HasConstraintName("FK_Registration_Person"); entity.HasOne(d => d.Sport).WithMany(p => p.Registrations) .HasForeignKey(d => d.SportId) .HasConstraintName("FK_Registration_Sport"); }); modelBuilder.Entity(entity => { entity.ToTable("Sport"); entity.HasIndex(e => e.Name, "UQ_Sport_Name").IsUnique(); entity.Property(e => e.Name) .HasMaxLength(100) .IsUnicode(false); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }