Skip to content

Add FerretDB Integration #432

@Matthewsre

Description

@Matthewsre

.NET Aspire issue link

dotnet/aspire#7322

Overview

I have an ASP.NET application that uses both PostgreSQL and MongoDB. FerretDB (powered by DocumentDB, which was recently open-sourced by Microsoft) provides a MongoDB-compatible layer on top of PostgreSQL. I would like an official way to configure FerretDB within .NET Aspire so I can either replace MongoDB entirely or simplify infrastructure.

Usage example

A straightforward integration in .NET Aspire similar to existing data providers/integrations. Since this provides a MongoDB compatibility layer, ideally it could be used the same way as the MongoDB integration (https://learn.microsoft.com/en-us/dotnet/aspire/database/mongodb-integration?tabs=dotnet-cli):

var builder = DistributedApplication.CreateBuilder(args);

var ferret = builder.AddFerretDB("mongo")
                   .WithLifetime(ContainerLifetime.Persistent);

var ferretdb = ferret .AddDatabase("mongodb");

builder.AddProject<Projects.ExampleProject>()
       .WithReference(ferretdb)
       .WaitFor(ferretdb);

Another consideration is leveraging an existing PostgreSQL, not sure what that would really look like to implement, but for the sake of providing a pseudo example:

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres");
var postgresdb = postgres.AddDatabase("postgresdb");

var ferret = builder.AddFerretDB("mongo")
                   .WithReference(postgres)
                   .WithLifetime(ContainerLifetime.Persistent);

var ferretdb = ferret .AddDatabase("mongodb");

builder.AddProject<Projects.ExampleProject>()
       .WithReference(postgresdb)
       .WithReference(ferretdb)
       .WaitFor(ferretdb);

Additional context

Help us help you

No, just wanted to propose this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions