Files
jellyfin/src/Jellyfin.Database
Bond-009 96269ff177
Some checks failed
Stale PR Check / Check PRs with merge conflicts (push) Has been cancelled
Stale Issue Labeler / Check for stale issues (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
OpenAPI Publish / OpenAPI - Publish Artifact (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
OpenAPI Publish / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI Publish / OpenAPI - Publish Stable Spec (push) Has been cancelled
Merge pull request #15355 from twsouthwick/twsouthwick-patch-1
Enable jellyfin.db customized path
2026-04-18 19:09:33 +02:00
..
2025-03-24 10:16:25 +00:00

How to run EFCore migrations

This shall provide context on how to work with entity frameworks multi provider migration feature.

Jellyfin will support multiple database providers in the future, namely SQLite as its default and the experimental PostgreSQL.

Each provider has its own set of migrations, as they contain provider specific instructions to migrate the specific changes to their respective systems.

When creating a new migration, you always have to create migrations for all providers. This is supported via the following syntax:

dotnet ef migrations add MIGRATION_NAME --project "PATH_TO_PROJECT" -- --provider PROVIDER_KEY

with SQLite currently being the only supported provider, you need to run the Entity Framework tool with the correct project to tell EFCore where to store the migrations and the correct provider key to tell Jellyfin to load that provider.

The example is made from the root folder of the project e.g for codespaces /workspaces/jellyfin

dotnet ef migrations add {MIGRATION_NAME} --project "src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite" -- --migration-provider Jellyfin-SQLite

If you get the error: Run "dotnet tool restore" to make the "dotnet-ef" command available. Run dotnet restore.

in the event that you get the error: System.UnauthorizedAccessException: Access to the path '/src/Jellyfin.Database' is denied. you have to restore as sudo and then run ef migrations as sudo too.