diff --git a/util/Seeder/Pipeline/BulkCommitter.cs b/util/Seeder/Pipeline/BulkCommitter.cs
index 454ec52d8e71..f618f2667c43 100644
--- a/util/Seeder/Pipeline/BulkCommitter.cs
+++ b/util/Seeder/Pipeline/BulkCommitter.cs
@@ -2,6 +2,7 @@
using Bit.Infrastructure.EntityFramework.Repositories;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
using EfCollection = Bit.Infrastructure.EntityFramework.Models.Collection;
using EfCollectionGroup = Bit.Infrastructure.EntityFramework.Models.CollectionGroup;
using EfCollectionUser = Bit.Infrastructure.EntityFramework.Models.CollectionUser;
@@ -25,8 +26,9 @@ namespace Bit.Seeder.Pipeline;
/// Each list is cleared after insert so the context is ready for the next pipeline run.
///
/// CollectionUser and CollectionGroup require an explicit table name in BulkCopyOptions because
-/// they lack both IEntityTypeConfiguration and .ToTable() mappings in DatabaseContext, so LinqToDB
-/// cannot resolve their table names automatically.
+/// they lack .ToTable() mappings in DatabaseContext, so LinqToDB cannot resolve their table names
+/// automatically. Table names vary by provider — SQL Server uses singular names while EF Core-managed
+/// providers use pluralized names.
///
///
///
@@ -48,9 +50,11 @@ internal void Commit(SeederContext context)
MapCopyAndClear(context.Collections);
- MapCopyAndClear(context.CollectionUsers, nameof(Core.Entities.CollectionUser));
+ MapCopyAndClear(context.CollectionUsers,
+ GetTableName());
- MapCopyAndClear(context.CollectionGroups, nameof(Core.Entities.CollectionGroup));
+ MapCopyAndClear(context.CollectionGroups,
+ GetTableName());
MapCopyAndClear(context.Folders);
@@ -59,6 +63,15 @@ internal void Commit(SeederContext context)
CopyAndClear(context.CollectionCiphers);
}
+ ///
+ /// Resolves the table name for an EF entity type from the EF Core model,
+ /// falling back to the C# class name for SQL Server.
+ ///
+ private string? GetTableName() where TEf : class =>
+ db.Database.IsSqlServer()
+ ? typeof(TEf).Name
+ : db.Model.FindEntityType(typeof(TEf))?.GetTableName();
+
private void MapCopyAndClear(List entities, string? tableName = null) where TEf : class
{
if (entities.Count is 0)