Summary

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

History

Metrics

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

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using ProjectX.Entities;
 3using ServiceBase;
 4
 5namespace ProjectX.Ef.Maps
 6{
 7    public static class UserMap
 8    {
 9        /// <summary>
 10        /// Performs configuration of a <see cref="User"/> entity type in the
 11        /// model.
 12        /// </summary>
 13        /// <param name="modelBuilder">See <see cref="ModelBuilder"/></param>
 14        public static void MapUserEntity(this ModelBuilder modelBuilder)
 15        {
 316            modelBuilder.Entity<User>(entity =>
 317            {
 618                entity.ToTable(Inflector.Pluralize(nameof(User).ToLower()));
 619                entity.HasKey(x => x.Id);
 320
 621                entity.Property(x => x.Name).HasMaxLength(100);
 622                entity.Property(x => x.Age);
 623                entity.Property(x => x.Gender);
 624                entity.Property(x => x.Info).HasMaxLength(512);
 325
 626                entity.Property(x => x.Perimeter);
 627                entity.Property(x => x.AgeFrom);
 628                entity.Property(x => x.AgeTo);
 329
 630                entity.Property(x => x.Locale).HasMaxLength(2);
 631                entity.Property(x => x.Phone).HasMaxLength(100);
 632                entity.Property(x => x.Hash).HasMaxLength(512);
 633                entity.Property(x => x.ClientOS);
 634                entity.Property(x => x.Code).HasMaxLength(4);
 635                entity.Property(x => x.ConfirmedAt);
 336
 637                entity.Property(x => x.CreatedAt);
 638                entity.Property(x => x.UpdatedAt);
 639                entity.Property(x => x.DeletedAt);
 340
 641                entity.HasIndex(x => x.Phone).IsUnique();
 342
 643                entity.HasMany(x => x.Images)
 644                    .WithOne(x => x.User)
 645                    .IsRequired()
 646                    .OnDelete(DeleteBehavior.Cascade);
 347
 648                entity.HasOne(x => x.CreatedBy)
 649                  .WithMany()
 650                  .IsRequired(false)
 651                  .OnDelete(DeleteBehavior.SetNull)
 652                  .HasForeignKey(x => x.CreatedById);
 353
 654                entity.HasOne(x => x.UpdatedBy)
 655                  .WithMany()
 656                  .IsRequired(false)
 657                  .OnDelete(DeleteBehavior.SetNull)
 658                  .HasForeignKey(x => x.UpdatedById);
 359
 660                entity.HasOne(x => x.DeletedBy)
 661                  .WithMany()
 662                  .IsRequired(false)
 663                  .OnDelete(DeleteBehavior.SetNull)
 664                  .HasForeignKey(x => x.DeletedById);
 665            });
 366        }
 67    }
 68}