Summary

Class:ProjectX.Ef.Maps.EventMap
Assembly:ProjectX.Ef
File(s):C:\private\projects\projectx\backend\src\ProjectX.Ef\Maps\EventMap.cs
Covered lines:40
Uncovered lines:0
Coverable lines:40
Total lines:57
Line coverage:100%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
MapEventEntity(...)20100100

File(s)

C:\private\projects\projectx\backend\src\ProjectX.Ef\Maps\EventMap.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using ProjectX.Entities;
 3using ServiceBase;
 4
 5namespace ProjectX.Ef.Maps
 6{
 7    public static class EventMap
 8    {
 9        /// <summary>
 10        /// Performs configuration of a <see cref="Event"/> entity type in
 11        /// the model.
 12        /// </summary>
 13        /// <param name="modelBuilder">See <see cref="ModelBuilder"/></param>
 14        public static void MapEventEntity(this ModelBuilder modelBuilder)
 15        {
 316            modelBuilder.Entity<Event>(entity =>
 317            {
 618                entity.ToTable(Inflector.Pluralize(nameof(Event).ToLower()));
 619                entity.HasKey(x => x.Id);
 320
 621                entity.Property(x => x.Title).HasMaxLength(100);
 622                entity.Property(x => x.Info).HasMaxLength(512);
 623                entity.Property(x => x.Latitude);
 624                entity.Property(x => x.Longitude);
 625                entity.Property(x => x.DateFrom);
 626                entity.Property(x => x.DateTo);
 327
 628                entity.Property(x => x.CreatedAt);
 629                entity.Property(x => x.UpdatedAt);
 630                entity.Property(x => x.DeletedAt);
 331
 632                entity.HasMany(x => x.Participants)
 633                    .WithOne(x => x.Event)
 634                    .IsRequired()
 635                    .OnDelete(DeleteBehavior.Cascade);
 336
 637                entity.HasOne(x => x.CreatedBy)
 638                  .WithMany()
 639                  .IsRequired(false)
 640                  .OnDelete(DeleteBehavior.SetNull)
 641                  .HasForeignKey(x => x.CreatedById);
 342
 643                entity.HasOne(x => x.UpdatedBy)
 644                  .WithMany()
 645                  .IsRequired(false)
 646                  .OnDelete(DeleteBehavior.SetNull)
 647                  .HasForeignKey(x => x.UpdatedById);
 348
 649                entity.HasOne(x => x.DeletedBy)
 650                  .WithMany()
 651                  .IsRequired(false)
 652                  .OnDelete(DeleteBehavior.SetNull)
 653                  .HasForeignKey(x => x.DeletedById);
 654            });
 355        }
 56    }
 57}