How borisdj/efcore.bulkextensions works
Project Type and Purpose
• This is an open-source .NET class library (EFCore.BulkExtensions) that plugs into Entity Framework Core to provide ultra-fast bulk CRUD operations across multiple SQL database providers.
• Its core use cases are high-volume Insert/Update/Delete/Upsert/Read/Sync calls on EF Core DbContext, with provider-specific optimizations (SQL Server, PostgreSQL, MySQL, Oracle, SQLite).
High-Level Architecture (file-structure analysis)
• EFCore.BulkExtensions.sln
• EFCore.BulkExtensions.Core (shared core logic)
• EFCore.BulkExtensions.SqlServer (/PostgreSql, /MySql, /Oracle, /Sqlite) – each implements the SQL-dialect adapter interfaces defined in Core
• EFCore.BulkExtensions (main NuGet package) – aggregates all provider packages
• EFCore.BulkExtensions.Tests – integration & unit tests, Docker Compose for test DBs
• Directory.Build.props, CI workflows, CONTRIBUTING, GitHub Actions under .github/workflows
Key Components
a. EFCore.BulkExtensions.Core
• Contains extension methods (BulkInsert, BulkUpdate, BulkDelete, etc.) on DbContext
• Defines interfaces: ISqlOperationsAdapter, ISqlDialect, IDbServer
• Implements the orchestration: building temp tables, MERGE/COPY/UPSERT statements, BulkConfig, stats, transaction management
b. Provider Adapter Libraries (SqlServer, PostgreSql, MySql, Oracle, Sqlite)
• Each library implements the core interfaces for its SQL dialect (QueryBuilder, DbServer, Adapter)
• Contains provider-specific SQL builders and low-level calls (e.g., SqlBulkCopy for SQL Server, COPY for Postgres)
c. EFCore.BulkExtensions (aggregate NuGet)
• References Core + all provider libraries
• Single-point package for users
d. Entity Framework Core (external)
• Provides DbContext, ChangeTracker, EF Core metadata
• The user-land application code calls BulkExtensions extension methods on DbContext
e. Databases (external)
• Five target RDBMS instances: SQL Server, PostgreSQL, MySQL, Oracle, SQLite
f. Tests & CI/CD
• EFCore.BulkExtensions.Tests uses Docker Compose to spin up real database containers
• GitHub Actions workflows: build → test → security scan → publish NuGet
Relationships & Data Flow
• User Code → calls DbContext.BulkInsert(…)
• Extension method from Core library orchestrates:
→ BulkConfig
→ Temporary table creation (in tempdb or schema)
→ Bulk data load via DataReader or bulk API
→ MERGE / COPY / UPSERT SQL generated by SqlQueryBuilder (provider adapter)
→ Commit transaction
→ (Optional) OUTPUT identity or stats back into entity objects
• Core library depends on EFCore metadata + adapter interfaces
• Provider libs implement those interfaces and register with Core via DI or static mapping (SqlAdaptersMapping)
• Main package ties Core + all providers for easy NuGet consumption
• Tests validate each code path against live DB containers
Architectural Patterns & Principles
• Adapter / Plugin Pattern – pluggable SQL-dialect modules implementing a common interface
• Single Responsibility – Core focuses on orchestration, adapters focus on SQL generation/execution
• Dependency Inversion – Core depends on SQL adapter interfaces; concrete providers injected at runtime
• Extension Methods – augment DbContext with bulk methods for seamless EF Core integration
• Modular multi-project solution – separate projects per provider for lighter NuGet packages
Essential Elements
• Clear component labels and grouping (Core vs Adapters vs Tests vs External)
• Annotation of key protocols/technologies: .NET 9, EF Core 9, SqlBulkCopy, COPY BINARY, ON DUPLICATE, MERGE
• BulkConfig / transaction boundary around bulk operations