Not Able To Use UseInMemoryDatabase method In DbContextOptionsBuilder

While working on this demo project, I got this error below

Problem with UseInMemoryDatabase Method

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS1061	'DbContextOptionsBuilder' does not contain a definition for 'UseInMemoryDatabase' and no accessible extension method 'UseInMemoryDatabase' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)	WebDemoProject	C:\Users\J\Startup.cs	32	Active

Solution

According to EntityFramework Core, in order to be able to use the InMemory reference, you need to have Microsoft.EntityFrameworkCore.InMemory package installed to have access to UseInMemoryDatabase() extension method with DbContextOptionsBuilder. Once I read that and installed it. Voila everything works like champ.

Install-Package Microsoft.EntityFrameworkCore.InMemory

Leave a Reply

Your email address will not be published. Required fields are marked *