浏览代码

Remove constructor side effects and remove unneeded parameterless constructors

Patrick Barron 4 年之前
父节点
当前提交
287dab4655
共有 46 个文件被更改,包括 46 次插入627 次删除
  1. 0 9
      Jellyfin.Data/Entities/AccessSchedule.cs
  2. 2 11
      Jellyfin.Data/Entities/ActivityLog.cs
  3. 5 12
      Jellyfin.Data/Entities/CustomItemDisplayPreferences.cs
  4. 0 7
      Jellyfin.Data/Entities/DisplayPreferences.cs
  5. 0 10
      Jellyfin.Data/Entities/Group.cs
  6. 0 10
      Jellyfin.Data/Entities/ImageInfo.cs
  7. 0 7
      Jellyfin.Data/Entities/ItemDisplayPreferences.cs
  8. 1 14
      Jellyfin.Data/Entities/Libraries/Artwork.cs
  9. 2 1
      Jellyfin.Data/Entities/Libraries/Book.cs
  10. 1 20
      Jellyfin.Data/Entities/Libraries/BookMetadata.cs
  11. 1 19
      Jellyfin.Data/Entities/Libraries/Chapter.cs
  12. 0 39
      Jellyfin.Data/Entities/Libraries/CollectionItem.cs
  13. 1 14
      Jellyfin.Data/Entities/Libraries/Company.cs
  14. 1 16
      Jellyfin.Data/Entities/Libraries/CompanyMetadata.cs
  15. 2 1
      Jellyfin.Data/Entities/Libraries/CustomItem.cs
  16. 1 18
      Jellyfin.Data/Entities/Libraries/CustomItemMetadata.cs
  17. 2 20
      Jellyfin.Data/Entities/Libraries/Episode.cs
  18. 1 19
      Jellyfin.Data/Entities/Libraries/EpisodeMetadata.cs
  19. 1 25
      Jellyfin.Data/Entities/Libraries/Genre.cs
  20. 0 10
      Jellyfin.Data/Entities/Libraries/ItemMetadata.cs
  21. 0 10
      Jellyfin.Data/Entities/Libraries/Library.cs
  22. 0 7
      Jellyfin.Data/Entities/Libraries/LibraryItem.cs
  23. 1 19
      Jellyfin.Data/Entities/Libraries/MediaFile.cs
  24. 1 20
      Jellyfin.Data/Entities/Libraries/MediaFileStream.cs
  25. 0 10
      Jellyfin.Data/Entities/Libraries/MetadataProvider.cs
  26. 1 19
      Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs
  27. 2 1
      Jellyfin.Data/Entities/Libraries/Movie.cs
  28. 1 14
      Jellyfin.Data/Entities/Libraries/MovieMetadata.cs
  29. 2 1
      Jellyfin.Data/Entities/Libraries/MusicAlbum.cs
  30. 1 14
      Jellyfin.Data/Entities/Libraries/MusicAlbumMetadata.cs
  31. 0 10
      Jellyfin.Data/Entities/Libraries/Person.cs
  32. 1 21
      Jellyfin.Data/Entities/Libraries/PersonRole.cs
  33. 2 1
      Jellyfin.Data/Entities/Libraries/Photo.cs
  34. 1 20
      Jellyfin.Data/Entities/Libraries/PhotoMetadata.cs
  35. 1 20
      Jellyfin.Data/Entities/Libraries/Rating.cs
  36. 1 20
      Jellyfin.Data/Entities/Libraries/RatingSource.cs
  37. 1 14
      Jellyfin.Data/Entities/Libraries/Release.cs
  38. 2 20
      Jellyfin.Data/Entities/Libraries/Season.cs
  39. 1 19
      Jellyfin.Data/Entities/Libraries/SeasonMetadata.cs
  40. 2 1
      Jellyfin.Data/Entities/Libraries/Series.cs
  41. 1 20
      Jellyfin.Data/Entities/Libraries/SeriesMetadata.cs
  42. 2 20
      Jellyfin.Data/Entities/Libraries/Track.cs
  43. 1 20
      Jellyfin.Data/Entities/Libraries/TrackMetadata.cs
  44. 0 8
      Jellyfin.Data/Entities/Permission.cs
  45. 0 8
      Jellyfin.Data/Entities/Preference.cs
  46. 0 8
      Jellyfin.Data/Entities/User.cs

+ 0 - 9
Jellyfin.Data/Entities/AccessSchedule.cs

@@ -1,7 +1,6 @@
 using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
-using System.Text.Json.Serialization;
 using System.Xml.Serialization;
 using Jellyfin.Data.Enums;
 
@@ -27,14 +26,6 @@ namespace Jellyfin.Data.Entities
             EndHour = endHour;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="AccessSchedule"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected AccessSchedule()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id of this instance.
         /// </summary>

+ 2 - 11
Jellyfin.Data/Entities/ActivityLog.cs

@@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities
         /// <param name="name">The name.</param>
         /// <param name="type">The type.</param>
         /// <param name="userId">The user id.</param>
-        /// <param name="logLevel">The log level.</param>
-        public ActivityLog(string name, string type, Guid userId, LogLevel logLevel = LogLevel.Information)
+        public ActivityLog(string name, string type, Guid userId)
         {
             if (string.IsNullOrEmpty(name))
             {
@@ -35,15 +34,7 @@ namespace Jellyfin.Data.Entities
             Type = type;
             UserId = userId;
             DateCreated = DateTime.UtcNow;
-            LogSeverity = logLevel;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ActivityLog"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected ActivityLog()
-        {
+            LogSeverity = LogLevel.Information;
         }
 
         /// <summary>

+ 5 - 12
Jellyfin.Data/Entities/CustomItemDisplayPreferences.cs

@@ -15,22 +15,15 @@ namespace Jellyfin.Data.Entities
         /// <param name="userId">The user id.</param>
         /// <param name="itemId">The item id.</param>
         /// <param name="client">The client.</param>
-        /// <param name="preferenceKey">The preference key.</param>
-        /// <param name="preferenceValue">The preference value.</param>
-        public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string preferenceKey, string preferenceValue)
+        /// <param name="key">The preference key.</param>
+        /// <param name="value">The preference value.</param>
+        public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string key, string value)
         {
             UserId = userId;
             ItemId = itemId;
             Client = client;
-            Key = preferenceKey;
-            Value = preferenceValue;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CustomItemDisplayPreferences"/> class.
-        /// </summary>
-        protected CustomItemDisplayPreferences()
-        {
+            Key = key;
+            Value = value;
         }
 
         /// <summary>

+ 0 - 7
Jellyfin.Data/Entities/DisplayPreferences.cs

@@ -36,13 +36,6 @@ namespace Jellyfin.Data.Entities
             HomeSections = new HashSet<HomeSection>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="DisplayPreferences"/> class.
-        /// </summary>
-        protected DisplayPreferences()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the Id.
         /// </summary>

+ 0 - 10
Jellyfin.Data/Entities/Group.cs

@@ -32,16 +32,6 @@ namespace Jellyfin.Data.Entities
             Preferences = new HashSet<Preference>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Group"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Group()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id of this group.
         /// </summary>

+ 0 - 10
Jellyfin.Data/Entities/ImageInfo.cs

@@ -19,16 +19,6 @@ namespace Jellyfin.Data.Entities
             LastModified = DateTime.UtcNow;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ImageInfo"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected ImageInfo()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 0 - 7
Jellyfin.Data/Entities/ItemDisplayPreferences.cs

@@ -28,13 +28,6 @@ namespace Jellyfin.Data.Entities
             RememberIndexing = false;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ItemDisplayPreferences"/> class.
-        /// </summary>
-        protected ItemDisplayPreferences()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the Id.
         /// </summary>

+ 1 - 14
Jellyfin.Data/Entities/Libraries/Artwork.cs

@@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="path">The path.</param>
         /// <param name="kind">The kind of art.</param>
-        /// <param name="owner">The owner.</param>
-        public Artwork(string path, ArtKind kind, IHasArtwork owner)
+        public Artwork(string path, ArtKind kind)
         {
             if (string.IsNullOrEmpty(path))
             {
@@ -28,18 +27,6 @@ namespace Jellyfin.Data.Entities.Libraries
 
             Path = path;
             Kind = kind;
-
-            owner?.Artwork.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Artwork"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Artwork()
-        {
         }
 
         /// <summary>

+ 2 - 1
Jellyfin.Data/Entities/Libraries/Book.cs

@@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Book"/> class.
         /// </summary>
-        public Book()
+        /// <param name="library">The library.</param>
+        public Book(Library library) : base(library)
         {
             BookMetadata = new HashSet<BookMetadata>();
             Releases = new HashSet<Release>();

+ 1 - 20
Jellyfin.Data/Entities/Libraries/BookMetadata.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -17,29 +16,11 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="book">The book.</param>
-        public BookMetadata(string title, string language, Book book) : base(title, language)
+        public BookMetadata(string title, string language) : base(title, language)
         {
-            if (book == null)
-            {
-                throw new ArgumentNullException(nameof(book));
-            }
-
-            book.BookMetadata.Add(this);
-
             Publishers = new HashSet<Company>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="BookMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected BookMetadata()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the ISBN.
         /// </summary>

+ 1 - 19
Jellyfin.Data/Entities/Libraries/Chapter.cs

@@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
         /// <param name="startTime">The start time for this chapter.</param>
-        /// <param name="release">The release.</param>
-        public Chapter(string language, long startTime, Release release)
+        public Chapter(string language, long startTime)
         {
             if (string.IsNullOrEmpty(language))
             {
@@ -27,23 +26,6 @@ namespace Jellyfin.Data.Entities.Libraries
 
             Language = language;
             StartTime = startTime;
-
-            if (release == null)
-            {
-                throw new ArgumentNullException(nameof(release));
-            }
-
-            release.Chapters.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Chapter"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Chapter()
-        {
         }
 
         /// <summary>

+ 0 - 39
Jellyfin.Data/Entities/Libraries/CollectionItem.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -10,44 +9,6 @@ namespace Jellyfin.Data.Entities.Libraries
     /// </summary>
     public class CollectionItem : IHasConcurrencyToken
     {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CollectionItem"/> class.
-        /// </summary>
-        /// <param name="collection">The collection.</param>
-        /// <param name="previous">The previous item.</param>
-        /// <param name="next">The next item.</param>
-        public CollectionItem(Collection collection, CollectionItem previous, CollectionItem next)
-        {
-            if (collection == null)
-            {
-                throw new ArgumentNullException(nameof(collection));
-            }
-
-            collection.Items.Add(this);
-
-            if (next != null)
-            {
-                Next = next;
-                next.Previous = this;
-            }
-
-            if (previous != null)
-            {
-                Previous = previous;
-                previous.Next = this;
-            }
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CollectionItem"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected CollectionItem()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 14
Jellyfin.Data/Entities/Libraries/Company.cs

@@ -15,24 +15,11 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Company"/> class.
         /// </summary>
-        /// <param name="owner">The owner of this company.</param>
-        public Company(IHasCompanies owner)
+        public Company()
         {
-            owner?.Companies.Add(this);
-
             CompanyMetadata = new HashSet<CompanyMetadata>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Company"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Company()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 16
Jellyfin.Data/Entities/Libraries/CompanyMetadata.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 
 namespace Jellyfin.Data.Entities.Libraries
@@ -13,21 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="company">The company.</param>
-        public CompanyMetadata(string title, string language, Company company) : base(title, language)
-        {
-            if (company == null)
-            {
-                throw new ArgumentNullException(nameof(company));
-            }
-
-            company.CompanyMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CompanyMetadata"/> class.
-        /// </summary>
-        protected CompanyMetadata()
+        public CompanyMetadata(string title, string language) : base(title, language)
         {
         }
 

+ 2 - 1
Jellyfin.Data/Entities/Libraries/CustomItem.cs

@@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="CustomItem"/> class.
         /// </summary>
-        public CustomItem()
+        /// <param name="library">The library.</param>
+        public CustomItem(Library library) : base(library)
         {
             CustomItemMetadata = new HashSet<CustomItemMetadata>();
             Releases = new HashSet<Release>();

+ 1 - 18
Jellyfin.Data/Entities/Libraries/CustomItemMetadata.cs

@@ -12,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="item">The item.</param>
-        public CustomItemMetadata(string title, string language, CustomItem item) : base(title, language)
-        {
-            if (item == null)
-            {
-                throw new ArgumentNullException(nameof(item));
-            }
-
-            item.CustomItemMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CustomItemMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected CustomItemMetadata()
+        public CustomItemMetadata(string title, string language) : base(title, language)
         {
         }
     }

+ 2 - 20
Jellyfin.Data/Entities/Libraries/Episode.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 using Jellyfin.Data.Interfaces;
 
@@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Episode"/> class.
         /// </summary>
-        /// <param name="season">The season.</param>
-        public Episode(Season season)
+        /// <param name="library">The library.</param>
+        public Episode(Library library) : base(library)
         {
-            if (season == null)
-            {
-                throw new ArgumentNullException(nameof(season));
-            }
-
-            season.Episodes.Add(this);
-
             Releases = new HashSet<Release>();
             EpisodeMetadata = new HashSet<EpisodeMetadata>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Episode"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Episode()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the episode number.
         /// </summary>

+ 1 - 19
Jellyfin.Data/Entities/Libraries/EpisodeMetadata.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 
 namespace Jellyfin.Data.Entities.Libraries
@@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="episode">The episode.</param>
-        public EpisodeMetadata(string title, string language, Episode episode) : base(title, language)
-        {
-            if (episode == null)
-            {
-                throw new ArgumentNullException(nameof(episode));
-            }
-
-            episode.EpisodeMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="EpisodeMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected EpisodeMetadata()
+        public EpisodeMetadata(string title, string language) : base(title, language)
         {
         }
 

+ 1 - 25
Jellyfin.Data/Entities/Libraries/Genre.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -14,32 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="Genre"/> class.
         /// </summary>
         /// <param name="name">The name.</param>
-        /// <param name="itemMetadata">The metadata.</param>
-        public Genre(string name, ItemMetadata itemMetadata)
+        public Genre(string name)
         {
-            if (string.IsNullOrEmpty(name))
-            {
-                throw new ArgumentNullException(nameof(name));
-            }
-
             Name = name;
-
-            if (itemMetadata == null)
-            {
-                throw new ArgumentNullException(nameof(itemMetadata));
-            }
-
-            itemMetadata.Genres.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Genre"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Genre()
-        {
         }
 
         /// <summary>

+ 0 - 10
Jellyfin.Data/Entities/Libraries/ItemMetadata.cs

@@ -42,16 +42,6 @@ namespace Jellyfin.Data.Entities.Libraries
             Sources = new HashSet<MetadataProviderId>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ItemMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to being abstract.
-        /// </remarks>
-        protected ItemMetadata()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 0 - 10
Jellyfin.Data/Entities/Libraries/Library.cs

@@ -24,16 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
             Name = name;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Library"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Library()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 0 - 7
Jellyfin.Data/Entities/Libraries/LibraryItem.cs

@@ -20,13 +20,6 @@ namespace Jellyfin.Data.Entities.Libraries
             Library = library;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="LibraryItem"/> class.
-        /// </summary>
-        protected LibraryItem()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 19
Jellyfin.Data/Entities/Libraries/MediaFile.cs

@@ -19,8 +19,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="path">The path relative to the LibraryRoot.</param>
         /// <param name="kind">The file kind.</param>
-        /// <param name="release">The release.</param>
-        public MediaFile(string path, MediaFileKind kind, Release release)
+        public MediaFile(string path, MediaFileKind kind)
         {
             if (string.IsNullOrEmpty(path))
             {
@@ -30,26 +29,9 @@ namespace Jellyfin.Data.Entities.Libraries
             Path = path;
             Kind = kind;
 
-            if (release == null)
-            {
-                throw new ArgumentNullException(nameof(release));
-            }
-
-            release.MediaFiles.Add(this);
-
             MediaFileStreams = new HashSet<MediaFileStream>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MediaFile"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MediaFile()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 20
Jellyfin.Data/Entities/Libraries/MediaFileStream.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -14,27 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="MediaFileStream"/> class.
         /// </summary>
         /// <param name="streamNumber">The number of this stream.</param>
-        /// <param name="mediaFile">The media file.</param>
-        public MediaFileStream(int streamNumber, MediaFile mediaFile)
+        public MediaFileStream(int streamNumber)
         {
             StreamNumber = streamNumber;
-
-            if (mediaFile == null)
-            {
-                throw new ArgumentNullException(nameof(mediaFile));
-            }
-
-            mediaFile.MediaFileStreams.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MediaFileStream"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MediaFileStream()
-        {
         }
 
         /// <summary>

+ 0 - 10
Jellyfin.Data/Entities/Libraries/MetadataProvider.cs

@@ -24,16 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
             Name = name;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MetadataProvider"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MetadataProvider()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 19
Jellyfin.Data/Entities/Libraries/MetadataProviderId.cs

@@ -14,8 +14,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
         /// </summary>
         /// <param name="providerId">The provider id.</param>
-        /// <param name="itemMetadata">The metadata entity.</param>
-        public MetadataProviderId(string providerId, ItemMetadata itemMetadata)
+        public MetadataProviderId(string providerId)
         {
             if (string.IsNullOrEmpty(providerId))
             {
@@ -23,23 +22,6 @@ namespace Jellyfin.Data.Entities.Libraries
             }
 
             ProviderId = providerId;
-
-            if (itemMetadata == null)
-            {
-                throw new ArgumentNullException(nameof(itemMetadata));
-            }
-
-            itemMetadata.Sources.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MetadataProviderId()
-        {
         }
 
         /// <summary>

+ 2 - 1
Jellyfin.Data/Entities/Libraries/Movie.cs

@@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Movie"/> class.
         /// </summary>
-        public Movie()
+        /// <param name="library">The library.</param>
+        public Movie(Library library) : base(library)
         {
             Releases = new HashSet<Release>();
             MovieMetadata = new HashSet<MovieMetadata>();

+ 1 - 14
Jellyfin.Data/Entities/Libraries/MovieMetadata.cs

@@ -17,22 +17,9 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the movie.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="movie">The movie.</param>
-        public MovieMetadata(string title, string language, Movie movie) : base(title, language)
+        public MovieMetadata(string title, string language) : base(title, language)
         {
             Studios = new HashSet<Company>();
-
-            movie.MovieMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MovieMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MovieMetadata()
-        {
         }
 
         /// <summary>

+ 2 - 1
Jellyfin.Data/Entities/Libraries/MusicAlbum.cs

@@ -12,7 +12,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="MusicAlbum"/> class.
         /// </summary>
-        public MusicAlbum()
+        /// <param name="library">The library.</param>
+        public MusicAlbum(Library library) : base(library)
         {
             MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>();
             Tracks = new HashSet<Track>();

+ 1 - 14
Jellyfin.Data/Entities/Libraries/MusicAlbumMetadata.cs

@@ -15,22 +15,9 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the album.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="album">The music album.</param>
-        public MusicAlbumMetadata(string title, string language, MusicAlbum album) : base(title, language)
+        public MusicAlbumMetadata(string title, string language) : base(title, language)
         {
             Labels = new HashSet<Company>();
-
-            album.MusicAlbumMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MusicAlbumMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected MusicAlbumMetadata()
-        {
         }
 
         /// <summary>

+ 0 - 10
Jellyfin.Data/Entities/Libraries/Person.cs

@@ -31,16 +31,6 @@ namespace Jellyfin.Data.Entities.Libraries
             Sources = new HashSet<MetadataProviderId>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Person"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Person()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 1 - 21
Jellyfin.Data/Entities/Libraries/PersonRole.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
@@ -18,31 +17,12 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="PersonRole"/> class.
         /// </summary>
         /// <param name="type">The role type.</param>
-        /// <param name="itemMetadata">The metadata.</param>
-        public PersonRole(PersonRoleType type, ItemMetadata itemMetadata)
+        public PersonRole(PersonRoleType type)
         {
             Type = type;
-
-            if (itemMetadata == null)
-            {
-                throw new ArgumentNullException(nameof(itemMetadata));
-            }
-
-            itemMetadata.PersonRoles.Add(this);
-
             Sources = new HashSet<MetadataProviderId>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PersonRole"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected PersonRole()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 2 - 1
Jellyfin.Data/Entities/Libraries/Photo.cs

@@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Photo"/> class.
         /// </summary>
-        public Photo()
+        /// <param name="library">The library.</param>
+        public Photo(Library library) : base(library)
         {
             PhotoMetadata = new HashSet<PhotoMetadata>();
             Releases = new HashSet<Release>();

+ 1 - 20
Jellyfin.Data/Entities/Libraries/PhotoMetadata.cs

@@ -1,5 +1,3 @@
-using System;
-
 namespace Jellyfin.Data.Entities.Libraries
 {
     /// <summary>
@@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the photo.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="photo">The photo.</param>
-        public PhotoMetadata(string title, string language, Photo photo) : base(title, language)
-        {
-            if (photo == null)
-            {
-                throw new ArgumentNullException(nameof(photo));
-            }
-
-            photo.PhotoMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PhotoMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected PhotoMetadata()
+        public PhotoMetadata(string title, string language) : base(title, language)
         {
         }
     }

+ 1 - 20
Jellyfin.Data/Entities/Libraries/Rating.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -14,27 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="Rating"/> class.
         /// </summary>
         /// <param name="value">The value.</param>
-        /// <param name="itemMetadata">The metadata.</param>
-        public Rating(double value, ItemMetadata itemMetadata)
+        public Rating(double value)
         {
             Value = value;
-
-            if (itemMetadata == null)
-            {
-                throw new ArgumentNullException(nameof(itemMetadata));
-            }
-
-            itemMetadata.Ratings.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Rating"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Rating()
-        {
         }
 
         /// <summary>

+ 1 - 20
Jellyfin.Data/Entities/Libraries/RatingSource.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using Jellyfin.Data.Interfaces;
@@ -15,28 +14,10 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="minimumValue">The minimum value.</param>
         /// <param name="maximumValue">The maximum value.</param>
-        /// <param name="rating">The rating.</param>
-        public RatingSource(double minimumValue, double maximumValue, Rating rating)
+        public RatingSource(double minimumValue, double maximumValue)
         {
             MinimumValue = minimumValue;
             MaximumValue = maximumValue;
-
-            if (rating == null)
-            {
-                throw new ArgumentNullException(nameof(rating));
-            }
-
-            rating.RatingType = this;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="RatingSource"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected RatingSource()
-        {
         }
 
         /// <summary>

+ 1 - 14
Jellyfin.Data/Entities/Libraries/Release.cs

@@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Initializes a new instance of the <see cref="Release"/> class.
         /// </summary>
         /// <param name="name">The name of this release.</param>
-        /// <param name="owner">The owner of this release.</param>
-        public Release(string name, IHasReleases owner)
+        public Release(string name)
         {
             if (string.IsNullOrEmpty(name))
             {
@@ -27,22 +26,10 @@ namespace Jellyfin.Data.Entities.Libraries
 
             Name = name;
 
-            owner?.Releases.Add(this);
-
             MediaFiles = new HashSet<MediaFile>();
             Chapters = new HashSet<Chapter>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Release"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Release()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id.
         /// </summary>

+ 2 - 20
Jellyfin.Data/Entities/Libraries/Season.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 
 namespace Jellyfin.Data.Entities.Libraries
@@ -13,30 +12,13 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Season"/> class.
         /// </summary>
-        /// <param name="series">The series.</param>
-        public Season(Series series)
+        /// <param name="library">The library.</param>
+        public Season(Library library) : base(library)
         {
-            if (series == null)
-            {
-                throw new ArgumentNullException(nameof(series));
-            }
-
-            series.Seasons.Add(this);
-
             Episodes = new HashSet<Episode>();
             SeasonMetadata = new HashSet<SeasonMetadata>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Season"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Season()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the season number.
         /// </summary>

+ 1 - 19
Jellyfin.Data/Entities/Libraries/SeasonMetadata.cs

@@ -1,4 +1,3 @@
-using System;
 using System.ComponentModel.DataAnnotations;
 
 namespace Jellyfin.Data.Entities.Libraries
@@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="season">The season.</param>
-        public SeasonMetadata(string title, string language, Season season) : base(title, language)
-        {
-            if (season == null)
-            {
-                throw new ArgumentNullException(nameof(season));
-            }
-
-            season.SeasonMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SeasonMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected SeasonMetadata()
+        public SeasonMetadata(string title, string language) : base(title, language)
         {
         }
 

+ 2 - 1
Jellyfin.Data/Entities/Libraries/Series.cs

@@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Series"/> class.
         /// </summary>
-        public Series()
+        /// <param name="library">The library.</param>
+        public Series(Library library) : base(library)
         {
             DateAdded = DateTime.UtcNow;
             Seasons = new HashSet<Season>();

+ 1 - 20
Jellyfin.Data/Entities/Libraries/SeriesMetadata.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
@@ -18,29 +17,11 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="series">The series.</param>
-        public SeriesMetadata(string title, string language, Series series) : base(title, language)
+        public SeriesMetadata(string title, string language) : base(title, language)
         {
-            if (series == null)
-            {
-                throw new ArgumentNullException(nameof(series));
-            }
-
-            series.SeriesMetadata.Add(this);
-
             Networks = new HashSet<Company>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SeriesMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected SeriesMetadata()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the outline.
         /// </summary>

+ 2 - 20
Jellyfin.Data/Entities/Libraries/Track.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CA2227
 
-using System;
 using System.Collections.Generic;
 using Jellyfin.Data.Interfaces;
 
@@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
         /// <summary>
         /// Initializes a new instance of the <see cref="Track"/> class.
         /// </summary>
-        /// <param name="album">The album.</param>
-        public Track(MusicAlbum album)
+        /// <param name="library">The library.</param>
+        public Track(Library library) : base(library)
         {
-            if (album == null)
-            {
-                throw new ArgumentNullException(nameof(album));
-            }
-
-            album.Tracks.Add(this);
-
             Releases = new HashSet<Release>();
             TrackMetadata = new HashSet<TrackMetadata>();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Track"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected Track()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the track number.
         /// </summary>

+ 1 - 20
Jellyfin.Data/Entities/Libraries/TrackMetadata.cs

@@ -1,5 +1,3 @@
-using System;
-
 namespace Jellyfin.Data.Entities.Libraries
 {
     /// <summary>
@@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// </summary>
         /// <param name="title">The title or name of the object.</param>
         /// <param name="language">ISO-639-3 3-character language codes.</param>
-        /// <param name="track">The track.</param>
-        public TrackMetadata(string title, string language, Track track) : base(title, language)
-        {
-            if (track == null)
-            {
-                throw new ArgumentNullException(nameof(track));
-            }
-
-            track.TrackMetadata.Add(this);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="TrackMetadata"/> class.
-        /// </summary>
-        /// <remarks>
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </remarks>
-        protected TrackMetadata()
+        public TrackMetadata(string title, string language) : base(title, language)
         {
         }
     }

+ 0 - 8
Jellyfin.Data/Entities/Permission.cs

@@ -22,14 +22,6 @@ namespace Jellyfin.Data.Entities
             Value = value;
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Permission"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected Permission()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id of this permission.
         /// </summary>

+ 0 - 8
Jellyfin.Data/Entities/Preference.cs

@@ -23,14 +23,6 @@ namespace Jellyfin.Data.Entities
             Value = value ?? throw new ArgumentNullException(nameof(value));
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Preference"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected Preference()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the id of this preference.
         /// </summary>

+ 0 - 8
Jellyfin.Data/Entities/User.cs

@@ -77,14 +77,6 @@ namespace Jellyfin.Data.Entities
             AddDefaultPreferences();
         }
 
-        /// <summary>
-        /// Initializes a new instance of the <see cref="User"/> class.
-        /// Default constructor. Protected due to required properties, but present because EF needs it.
-        /// </summary>
-        protected User()
-        {
-        }
-
         /// <summary>
         /// Gets or sets the Id of the user.
         /// </summary>