📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Should integration tests use the EF Core in-memory provider instead of a real database? Why or why not?

Beginner Theory Beginner

🎯 Key points

  • Runs LINQ in memory; never generates or tests SQL
  • No relational constraints, real transactions or SQL Server collation and null semantics
  • Microsoft's EF Core testing guidance discourages it
  • Acceptable only for fast logic tests where database behaviour is irrelevant
  • Integration tests: SQL Server via Testcontainers (seconds to start once, shared per collection)
  • SQLite in-memory is a compromise with a different dialect
  • Reset state with Respawn or rolled-back transactions

⏱ 30-second answer

Not for anything that tests data access. The EF Core in-memory provider runs LINQ against in-memory collections; it never generates SQL, so untranslatable queries, SQL Server collation and case-sensitivity, null semantics, constraints, foreign keys, unique indexes and transactions all behave differently, and tests pass that would fail on SQL Server. Microsoft's EF Core testing docs discourage it for testing. It can still serve quick tests of application logic that merely uses a DbContext, where speed matters more than fidelity. For integration tests use SQL Server in Testcontainers (or SQLite in-memory as a compromise with a different dialect), and reset state with Respawn or rolled-back transactions.

🔍 What the interviewer is checking

Checks the candidate knows the in-memory provider is not a relational database.

↩ Usually asked after

More in Test Types

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me