-
Notifications
You must be signed in to change notification settings - Fork 112
Description
.NET Aspire issue link
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
- FerretDB can be a drop-in replacement for MongoDB 5.0+ and could be useful for applications that rely on MongoDB tooling or drivers but want to store data in PostgreSQL.
- This would unify our relational and document data needs in one database, particularly appealing to .NET developers already using PostgreSQL/Aspire.
- FerretDB github repo: https://github.com/FerretDB/FerretDB
- DocumentDB Open-Source announcement: https://opensource.microsoft.com/blog/2025/01/23/documentdb-open-source-announcement/
- DocumentDB github repo: https://github.com/microsoft/documentdb
- Open feature request on Aspire for DocumentDB integration: Add DocumentDB support in .NET Aspire dotnet/aspire#7320
- Closed feature request on Aspire repo recommending submission here: Add FerretDB support in .NET Aspire dotnet/aspire#7322
Help us help you
No, just wanted to propose this