diff --git a/Jellyfin.Data/Entities/ActivityLog.cs b/Jellyfin.Data/Entities/ActivityLog.cs
index 8fbf6eaabf..522c206640 100644
--- a/Jellyfin.Data/Entities/ActivityLog.cs
+++ b/Jellyfin.Data/Entities/ActivityLog.cs
@@ -53,6 +53,7 @@ namespace Jellyfin.Data.Entities
/// The name.
/// The type.
/// The user's id.
+ /// The new instance.
public static ActivityLog Create(string name, string type, Guid userId)
{
return new ActivityLog(name, type, userId);
@@ -63,7 +64,7 @@ namespace Jellyfin.Data.Entities
*************************************************************************/
///
- /// Gets the identity of this instance.
+ /// Gets or sets the identity of this instance.
/// This is the key in the backing database.
///
[Key]
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 0b398b60cd..65ceee32bf 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
@@ -56,7 +55,7 @@ namespace Jellyfin.Server.Implementations.Activity
{
using var dbContext = _provider.CreateContext();
- var query = func(dbContext.ActivityLogs).OrderByDescending(entry => entry.DateCreated).AsQueryable();
+ var query = func(dbContext.ActivityLogs.OrderByDescending(entry => entry.DateCreated));
if (startIndex.HasValue)
{
@@ -69,12 +68,12 @@ namespace Jellyfin.Server.Implementations.Activity
}
// This converts the objects from the new database model to the old for compatibility with the existing API.
- var list = query.AsEnumerable().Select(ConvertToOldModel).ToList();
+ var list = query.Select(ConvertToOldModel).ToList();
return new QueryResult
{
Items = list,
- TotalRecordCount = dbContext.ActivityLogs.Count()
+ TotalRecordCount = func(dbContext.ActivityLogs).Count()
};
}
diff --git a/Jellyfin.Server.Implementations/JellyfinDb.cs b/Jellyfin.Server.Implementations/JellyfinDb.cs
index 23714b24a1..ec09a619f2 100644
--- a/Jellyfin.Server.Implementations/JellyfinDb.cs
+++ b/Jellyfin.Server.Implementations/JellyfinDb.cs
@@ -107,10 +107,11 @@ namespace Jellyfin.Server.Implementations
public override int SaveChanges()
{
- foreach (var entity in ChangeTracker.Entries().Where(e => e.State == EntityState.Modified))
+ foreach (var saveEntity in ChangeTracker.Entries()
+ .Where(e => e.State == EntityState.Modified)
+ .OfType())
{
- var saveEntity = entity.Entity as ISavingChanges;
- saveEntity?.OnSavingChanges();
+ saveEntity.OnSavingChanges();
}
return base.SaveChanges();
diff --git a/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs b/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs
index a1b58eb5a9..72a4a8c3b6 100644
--- a/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs
+++ b/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs
@@ -12,9 +12,7 @@ namespace Jellyfin.Server.Implementations.Migrations
public JellyfinDb CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder();
- optionsBuilder.UseSqlite(
- "Data Source=jellyfin.db",
- opt => opt.MigrationsAssembly("Jellyfin.Migrations"));
+ optionsBuilder.UseSqlite("Data Source=jellyfin.db");
return new JellyfinDb(optionsBuilder.Options);
}
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
index 1d684804da..6f4fc4f281 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
@@ -106,11 +106,10 @@ namespace Jellyfin.Server.Migrations.Routines
newEntry.ItemId = entry[5].ToString();
}
- // Since code references the Id of the entries, this needs to be inserted in order.
- // In order to do that, we insert one by one because EF Core doesn't provide a way to guarantee ordering for bulk inserts.
dbContext.ActivityLogs.Add(newEntry);
- dbContext.SaveChanges();
}
+
+ dbContext.SaveChanges();
}
try