File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
docs2/pages/ef-core-docs/documentations/batch-delete/scenarios Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments