Skip to content

Commit eefab6d

Browse files
authored
Create ef-core-batch-delete-inmemory.md
1 parent cfb5a87 commit eefab6d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
Permalink: ef-core-batch-delete-inmemory
3+
---
4+
5+
# EF Core InMemory
6+
7+
### Problem
8+
9+
You want to use **BatchDelete** with In Memory Testing for EF Core.
10+
11+
### Solution
12+
13+
Specify a DbContext factory in the **BatchDeleteManager** to enable BatchDelete with In Memory. A DbContext factory must be
14+
15+
{% include template-example.html %}
16+
```csharp
17+
18+
// Options
19+
var db = new DbContextOptionsBuilder();
20+
db.UseInMemoryDatabase();
21+
22+
// Specify InMemory DbContext Factory
23+
BatchDeleteManager.InMemoryDbContextFactory = () => new MyContext(db.Options);
24+
25+
// Use the same code as with Relational Database
26+
var _context = new MyContext(db.Options);
27+
_context.Foos.Delete();
28+
29+
```

0 commit comments

Comments
 (0)