The InMemory database provider is an exciting feature in newer versions of Entity Framework, Microsoft’s open source ORM (object-relational mapper) framework for ADO.Net. Entity Framework simplifies data access in your .Net application by allowing you to write code to perform CRUD operations without interacting with the underlying database provider directly.

The InMemory data provider in Entity Framework makes life simpler by letting you test the code of your ASP.Net app against an in-memory database instead of having to install and configure the real thing. In this article we’ll examine how we can work with the InMemory provider in Entity Framework Core to write and execute unit tests for an ASP.Net Core application.

Note that the InMemory database provider is a general purpose database (not a relational database) designed strictly for the purposes of testing your application’s code. The supported platforms include the following:

  • .Net Framework 4.5.1 onwards
  • .Net Core
  • Mono 4.2.0 onwards
  • Universal Windows Platform

Entity Framework Core database providers

Basically, you can choose from three database providers for working with an in-memory database in Entity Framework Core. You will generally use either the Microsoft.EntityFrameworkCore.Relational package or the Microsoft.EntityFrameworkCore.InMemory package, depending on whether or not you need the relational database capabilities. The third option is the Microsoft.EntityFrameworkCore.Sqlite provider, if you want to use the lightweight SQLite database in an in-memory mode.