Filter by title

In-Memory Database Provider

The Volo.Abp.MemoryDb package implements ABP repositories with an in-process database. It is useful for tests and other non-durable scenarios. Data is kept in the application process and is lost when the process stops.

Installation

Install the Volo.Abp.MemoryDb NuGet package in the data-access project:

abp add-package Volo.Abp.MemoryDb

The command adds the package and the AbpMemoryDbModule dependency to the module class. You can also configure the dependency manually as shown in the next section.

Configure the Module

Add AbpMemoryDbModule as a dependency of your module:

[DependsOn(typeof(AbpMemoryDbModule))]
public class MyDataModule : AbpModule
{
}

Create a MemoryDb Context

Derive a class from MemoryDbContext and return the entity types managed by the context:

public class MyMemoryDbContext : MemoryDbContext
{
    private static readonly Type[] EntityTypes =
    [
        typeof(Book),
        typeof(Author)
    ];

    public override IReadOnlyList<Type> GetEntityTypes()
    {
        return EntityTypes;
    }
}

Register the context in the ConfigureServices method of your module:

context.Services.AddMemoryDbContext<MyMemoryDbContext>(options =>
{
    options.AddDefaultRepositories();
});

AddDefaultRepositories() registers default repositories for the aggregate roots returned by the context. Pass includeAllEntities: true when default repositories are also needed for other entity types.

MemoryDb repositories use ABP's unit-of-work-aware database provider. Repository operations require an active unit of work.

JSON Serialization

MemoryDb stores serialized entity values. Configure Utf8JsonMemoryDbSerializerOptions to customize the underlying System.Text.Json options:

Configure<Utf8JsonMemoryDbSerializerOptions>(options =>
{
    options.JsonSerializerOptions.Converters.Add(
        new MyEntityJsonConverter()
    );
});

Contributors


Last updated: July 17, 2026 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

ABP Community Talks
Low-Code, High Precision
13 Aug, 17:00
Online
Watch the Event
ABP Live Webinar
Webinar Calendar Webinar Calendar
Discover
ABP Platform
Register Now
Oct 01
Thursday,
17:00 UTC
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.