dotnet / dotnet/efcore

New efcore provider: Implementing batched update support

Open
#35,512 14 comments 0 reactions 1 assignee Claimed by @AndriySvyryd View on GitHub
area-save-changes customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### Question

Greetings! I'm still plugging my way through an efcore implementation for a proprietary database engine. I've made quite a lot of progress, but noticed I'm not seeing batch support happening automatically. I'm not sure this is explicit bulk insert, but rather sending multiple updates delimited by semi colon or something. I've just got a few questions on implementation of this. [Article about batched updates](https://learn.microsoft.com/en-us/ef/core/performance/efficient-updating?tabs=ef7)

1. Its safe to assume that batched updates as discussed above are different than the bulk insert implementations floating around, right?
2. Do those batched updates handle inserts, and if so... how do people typically handle tracking insert id's for that?
3. For implementing, is it a simple matter of implementing `IModificationCommandBatchFactory` to handle that?
4. Is there any place anyone can point me to see a reference implementation?

I've got a sample project where I'm simply trying to insert a number of records by `AddRangeAsync` and then calling `SaveChangesAsync` and they seem to run as a bunch of different queries on the same connection. For this demo project I've also configured min of 1 and max of 50 for batched statement sizes. I just don't know if batched updates are only for updates, or if they should cover inserts as well.

Thank you for your time, and any pointers you might be able to give

### Your code

```csharp

```

### Stack traces

```text

```

### Verbose output

```text

```

### EF Core version

8.0.11

### Database provider

Custom

### Target framework

.net 8

### Operating system

Windows 11

### IDE

Visual Studio 2022

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.