< Summary - Jellyfin

Information
Class: Jellyfin.Database.Implementations.ModelConfiguration.UserConfiguration
Assembly: Jellyfin.Database.Implementations
File(s): /srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/UserConfiguration.cs
Line coverage
100%
Covered lines: 32
Uncovered lines: 0
Coverable lines: 32
Total lines: 55
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Configure(...)100%11100%

File(s)

/srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/UserConfiguration.cs

#LineLine coverage
 1using Jellyfin.Database.Implementations.Entities;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.EntityFrameworkCore.Metadata.Builders;
 4
 5namespace Jellyfin.Database.Implementations.ModelConfiguration
 6{
 7    /// <summary>
 8    /// FluentAPI configuration for the User entity.
 9    /// </summary>
 10    public class UserConfiguration : IEntityTypeConfiguration<User>
 11    {
 12        /// <inheritdoc/>
 13        public void Configure(EntityTypeBuilder<User> builder)
 14        {
 215            builder
 216                .Property(user => user.Username);
 17
 218            builder
 219                .HasOne(u => u.ProfileImage)
 220                .WithOne()
 221                .OnDelete(DeleteBehavior.Cascade);
 22
 223            builder
 224                .HasMany(u => u.Permissions)
 225                .WithOne()
 226                .HasForeignKey(p => p.UserId)
 227                .OnDelete(DeleteBehavior.Cascade);
 28
 229            builder
 230                .HasMany(u => u.Preferences)
 231                .WithOne()
 232                .HasForeignKey(p => p.UserId)
 233                .OnDelete(DeleteBehavior.Cascade);
 34
 235            builder
 236                .HasMany(u => u.AccessSchedules)
 237                .WithOne()
 238                .OnDelete(DeleteBehavior.Cascade);
 39
 240            builder
 241                .HasMany(u => u.DisplayPreferences)
 242                .WithOne()
 243                .OnDelete(DeleteBehavior.Cascade);
 44
 245            builder
 246                .HasMany(u => u.ItemDisplayPreferences)
 247                .WithOne()
 248                .OnDelete(DeleteBehavior.Cascade);
 49
 250            builder
 251                .HasIndex(entity => entity.Username)
 252                .IsUnique();
 253        }
 54    }
 55}