In this recipe, we will learn how to use the InMemory
provider option in EF DbContext
.
- First, let's see the rows contained in our
Book
table in theCookbook
database on SQL Server:
- We can see in the
OnConfiguring
method ofCookbookContext
that we use SQL Server as the provider:
- Let's create an MVC
Cookbook
controller and aBooks
view to see all the rows of theBook
table:
The Books
view should look as follows:
- Now we will install the necessary packages to use the new
InMemory
provider for EF Core. We can do that in one of three ways:
- One is by the NuGet Package Manager:
- The second method involves using the
Package Manager Console
by typing the following command:
- The second method involves using the
Install-Package EntityFramework.InMemory -pre
The output of the preceding command is as follows:
We can see the EntityFramework.InMemory
is installed:
- The third way involves directly typing the name of the package in the
project...
- The third way involves directly typing the name of the package in the