[PR #6049] EFCore Image model update and cleanup #10790

Open
opened 2026-02-07 06:26:44 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/6049
Author: @ferferga
Created: 5/15/2021
Status: 🔄 Open

Base: masterHead: efcore-update


📝 Commits (10+)

  • 985c06a Remove duplication moving ImageType to Jellyfin.Data
  • 5f7a9bb Remove duplicated DisplayPreferencesDto in MediaBrowser.Model in favor of Jellyfin.Api
  • e8fb220 Reference all ImageType to Jellyfin.Data
  • b7659a2 Remove all unused usings
  • 962d36e Finish Image entity
  • a251d1d Create EFCore migration
  • 2c4b51e Migrate users to the new image model
  • b87dbfb Fix concurrency error
  • 3266a5e Use ImageType.Profile for user profiles
  • d37d051 Use EFCore migrations only to migrate to the new image model

📊 Changes

132 files changed (+1173 additions, -459 deletions)

View changed files

📝 Emby.Dlna/Didl/DidlBuilder.cs (+1 -0)
📝 Emby.Drawing/ImageProcessor.cs (+2 -1)
📝 Emby.Photos/PhotoProvider.cs (+1 -0)
📝 Emby.Server.Implementations/Channels/ChannelImageProvider.cs (+1 -1)
📝 Emby.Server.Implementations/Collections/CollectionImageProvider.cs (+1 -1)
📝 Emby.Server.Implementations/Data/SqliteItemRepository.cs (+0 -2)
📝 Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs (+0 -1)
📝 Emby.Server.Implementations/IO/ManagedFileSystem.cs (+0 -2)
📝 Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs (+1 -1)
📝 Emby.Server.Implementations/Images/DynamicImageProvider.cs (+1 -0)
📝 Emby.Server.Implementations/Images/FolderImageProvider.cs (+0 -1)
📝 Emby.Server.Implementations/Images/GenreImageProvider.cs (+0 -1)
📝 Emby.Server.Implementations/Images/PlaylistImageProvider.cs (+1 -1)
📝 Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs (+0 -1)
📝 Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs (+1 -1)
📝 Jellyfin.Api/Controllers/ApiKeyController.cs (+0 -1)
📝 Jellyfin.Api/Controllers/ArtistsController.cs (+0 -1)
📝 Jellyfin.Api/Controllers/DisplayPreferencesController.cs (+4 -4)
📝 Jellyfin.Api/Controllers/DynamicHlsController.cs (+0 -1)
📝 Jellyfin.Api/Controllers/ImageController.cs (+6 -5)

...and 80 more files

📄 Description

Some of the entities defined in https://github.com/jellyfin/jellyfin/pull/2293 have changed, one of them being the images, which now include blurhashes.

Changes

  • Removed DisplayPreferencesDto in MediaBrowserModel, in favor of the new one defined in Jellyfin.Api
  • Renamed Artwork entity to Image (for clarity, as suggested by @dkanada https://github.com/jellyfin/jellyfin/pull/2293#issuecomment-619549080)
  • Added different fields for tracking file creation/modification date and database creation/modification date.
  • ImageType has been moved to Jellyfin.Data.Enums from MediaBrowser.Model.Entities, to remove the duplication that previously existed with ArtworkKind.
  • Created a migration that updates the model as described below, being skipped if MigrateUserDb is not applied yet.
  • Log a message when there are pending EFCore migrations, informing the user that they can take a while to complete and advising against shutting down the server while they're in progress.
  • Merged ImageInfos with Image. Detail of the changes:

New Image entity properties

public int Id
public string Path
public ImageType Type
public string? Blurhash
public DateTime LastModifiedDate = DateTime.UtcNow;
public DateTime AddedDate
public DateTime? FileCreationDate
public DateTime? FileModificationDate
public uint RowVersion

With ImageType being the current ImageType enum

Current Image entity properties

public int Id
public string Path
public ArtKind Kind
public uint RowVersion

Current ImageInfo properties

public int Id
public Guid? UserId
public string Path
public DateTime LastModified

Every image we have in the client has (or can potentially have) all those fields in common. There's now a single 1:M or 1:1 relationship between any entity and Image. Examples:

* Movie => 1 : M being M Image objects for the Primary, Background, Art, etc images
* Photo => 1 : 1 Photo entity storing shutter speed, GPS location, etc... And Image (type Primary, the default one) storing blurhash and the path on disk.
* User => 1 : 1 User storing all the user information and Image the profile photo.

In this PR, only used entities were changed to use the new Image entity, as the others haven't been migrated to EFCore yet and we have time to revisit the others as well.

Issues

After running the migration, Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException exceptions are thrown after doing calls to the API controllers, not sure why (I call SaveChanges during the migration). Stopping Jellyfin and starting it again fixes the problem and everything starts working correctly.

Fixed on Use EFCore migrations only to migrate to the new image model commit.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/6049 **Author:** [@ferferga](https://github.com/ferferga) **Created:** 5/15/2021 **Status:** 🔄 Open **Base:** `master` ← **Head:** `efcore-update` --- ### 📝 Commits (10+) - [`985c06a`](https://github.com/jellyfin/jellyfin/commit/985c06ac4bee87c21068008bb56e6aac7d4e02a0) Remove duplication moving ImageType to Jellyfin.Data - [`5f7a9bb`](https://github.com/jellyfin/jellyfin/commit/5f7a9bb078ef5431c45d307576e05d6768aea95d) Remove duplicated DisplayPreferencesDto in MediaBrowser.Model in favor of Jellyfin.Api - [`e8fb220`](https://github.com/jellyfin/jellyfin/commit/e8fb220363c7475009cd9f159cf3d302c81bb43e) Reference all ImageType to Jellyfin.Data - [`b7659a2`](https://github.com/jellyfin/jellyfin/commit/b7659a219c18102e57e25fc93ae1f9a88543f258) Remove all unused usings - [`962d36e`](https://github.com/jellyfin/jellyfin/commit/962d36ed7b4fb9c4c7e711abf253ca8ee2784352) Finish Image entity - [`a251d1d`](https://github.com/jellyfin/jellyfin/commit/a251d1df5774f77bbfee54790930fa8880a4ab4f) Create EFCore migration - [`2c4b51e`](https://github.com/jellyfin/jellyfin/commit/2c4b51ee3b4a056769225d03f94fa0031bceae01) Migrate users to the new image model - [`b87dbfb`](https://github.com/jellyfin/jellyfin/commit/b87dbfb37f59da0b62ae2b64d035d09ebdc1d804) Fix concurrency error - [`3266a5e`](https://github.com/jellyfin/jellyfin/commit/3266a5ed4fb2e27b6daf5af702223672a73b0f33) Use ImageType.Profile for user profiles - [`d37d051`](https://github.com/jellyfin/jellyfin/commit/d37d05104ffb85e220838d1bccef0e4532556741) Use EFCore migrations only to migrate to the new image model ### 📊 Changes **132 files changed** (+1173 additions, -459 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Dlna/Didl/DidlBuilder.cs` (+1 -0) 📝 `Emby.Drawing/ImageProcessor.cs` (+2 -1) 📝 `Emby.Photos/PhotoProvider.cs` (+1 -0) 📝 `Emby.Server.Implementations/Channels/ChannelImageProvider.cs` (+1 -1) 📝 `Emby.Server.Implementations/Collections/CollectionImageProvider.cs` (+1 -1) 📝 `Emby.Server.Implementations/Data/SqliteItemRepository.cs` (+0 -2) 📝 `Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs` (+0 -1) 📝 `Emby.Server.Implementations/IO/ManagedFileSystem.cs` (+0 -2) 📝 `Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs` (+1 -1) 📝 `Emby.Server.Implementations/Images/DynamicImageProvider.cs` (+1 -0) 📝 `Emby.Server.Implementations/Images/FolderImageProvider.cs` (+0 -1) 📝 `Emby.Server.Implementations/Images/GenreImageProvider.cs` (+0 -1) 📝 `Emby.Server.Implementations/Images/PlaylistImageProvider.cs` (+1 -1) 📝 `Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs` (+0 -1) 📝 `Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs` (+1 -1) 📝 `Jellyfin.Api/Controllers/ApiKeyController.cs` (+0 -1) 📝 `Jellyfin.Api/Controllers/ArtistsController.cs` (+0 -1) 📝 `Jellyfin.Api/Controllers/DisplayPreferencesController.cs` (+4 -4) 📝 `Jellyfin.Api/Controllers/DynamicHlsController.cs` (+0 -1) 📝 `Jellyfin.Api/Controllers/ImageController.cs` (+6 -5) _...and 80 more files_ </details> ### 📄 Description Some of the entities defined in https://github.com/jellyfin/jellyfin/pull/2293 have changed, one of them being the images, which now include blurhashes. **Changes** - Removed DisplayPreferencesDto in MediaBrowserModel, in favor of the new one defined in Jellyfin.Api - Renamed **Artwork** entity to **Image** (for clarity, as suggested by @dkanada https://github.com/jellyfin/jellyfin/pull/2293#issuecomment-619549080) - Added different fields for tracking file creation/modification date and database creation/modification date. - ImageType has been moved to ``Jellyfin.Data.Enums`` from ``MediaBrowser.Model.Entities``, to remove the duplication that previously existed with ``ArtworkKind``. - Created a migration that updates the model as described below, being skipped if ``MigrateUserDb`` is not applied yet. - Log a message when there are pending EFCore migrations, informing the user that they can take a while to complete and advising against shutting down the server while they're in progress. - Merged **ImageInfos** with **Image**. Detail of the changes: **New Image entity properties** ``` public int Id public string Path public ImageType Type public string? Blurhash public DateTime LastModifiedDate = DateTime.UtcNow; public DateTime AddedDate public DateTime? FileCreationDate public DateTime? FileModificationDate public uint RowVersion ``` *With ImageType being the current ImageType enum* **Current Image entity properties** ``` public int Id public string Path public ArtKind Kind public uint RowVersion ``` **Current ImageInfo properties** ``` public int Id public Guid? UserId public string Path public DateTime LastModified ``` Every image we have in the client has (or can potentially have) all those fields in common. There's now a single 1:M or 1:1 relationship between any entity and ``Image``. Examples: ``` * Movie => 1 : M being M Image objects for the Primary, Background, Art, etc images * Photo => 1 : 1 Photo entity storing shutter speed, GPS location, etc... And Image (type Primary, the default one) storing blurhash and the path on disk. * User => 1 : 1 User storing all the user information and Image the profile photo. ``` In this PR, only used entities were changed to use the new ``Image`` entity, as the others haven't been migrated to EFCore yet and we have time to revisit the others as well. **Issues** ~~After running the migration, ``Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException`` exceptions are thrown after doing calls to the API controllers, not sure why (I call ``SaveChanges`` during the migration). **Stopping Jellyfin and starting it again fixes the problem and everything starts working correctly**.~~ Fixed on **Use EFCore migrations only to migrate to the new image model** commit. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:26:44 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#10790