Aspire 13.2 is here, and has some new features that will make it easier for you to interact with your databases.
- Do you like Azure Data Lake Storage? We have a new Azure Data Lake Storage integration for you to use.
- Do you like MongoDB but want to define data in C#? Well, you can use the new MongoDB Entity Framework Core (EF Core) client integration.
There are also some other improvements to make your database life easier and smoother. Let’s take a closer look.
Two major new integrations
The new integrations broaden your choice of data storage for Aspire apps.
MongoDB Entity Framework Core
There’s been a MongoDB integration in Aspire for a long time, but it didn’t let you define documents in object-oriented code. Now, if you want to write C# to store and query documents in MongoDB, the new MongoDB EF Core integration has got your back. Plus you get production-ready health checks, automatic service discovery, and all the conveniences you’ve learned to expect from an Aspire database client.
Note
To use EF Core with Aspire and MongoDB, you add the existing MongoDB hosting integration as you did in previous versions. Then choose the new MongoDB EF Core client integration for your consuming APIs and other projects.Use the Aspire CLI to add the MongoDB hosting integration to the AppHost project:
aspire add mongo
This scaffolds the necessary NuGet package and wiring. In your AppHost, you can define a MongoDB service like this:
var mongodb = builder.AddMongoDB("mongodb")
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);
var apiService = builder.AddProject<Projects.ApiService>("api")
.WithReference(mongodb);
Then, in the projects that consume the MongoDB service, install the MongoDB EF Core client integration:
dotnet add package Aspire.MongoDB.EntityFrameworkCore
Next, in that project’s Program.cs file, call the AddMongoDBContext extension method. That will register the EF Core DbContext in the dependency injection container:
builder.AddMongoDbContext<MyDbContext>("mongodb", "mydb");
When you want to use the MongoDB client, get it from the DI container:
private readonly MyDbContext _context;
public ProductsController(MyDbContext context)
{
_context = context;
// Use the context to access the database here.
}
Note
Just like in any other EF Core project, you’ll have to define the database objects and context in your code. For more information, see https://learn.microsoft.com/ef/core/dbcontext-configuration/The integration automatically handles connection pooling, telemetry collection, and health checks. You get real-time visibility into your MongoDB queries without adding extra configuration code.
Azure Data Lake Storage
Azure Data Lake Storage (ADLS) integration opens up new possibilities for analytics and big data workloads. Whether you’re building data pipelines, ETL processes, or analytics platforms, Aspire’s ADLS integration brings the same production-grade service discovery and health checking you expect from a cloud-native platform.
To get started, install the Azure Storage hosting integration:
aspre add azure-storage
In your AppHost, add the Data Lake resources and pass them to client APIs:
var storage = builder.AddAzureStorage("azure-storage");
var dataLake = storage.AddDataLake("data-lake");
var fileSystem = storage.AddDataLakeFileSystem("data-lake-file-system");
var analyticsService = builder.AddProject<Projects.AnalyticsService>("analytics")
.WithReference(dataLake)
.WithReference(fileSystem);
Then, in the API that consumes the Data Lake resources, register them in the dependency injection container:
builder.AddAzureDataLakeServiceClient("data-lake");
builder.AddAzureDataLakeFileSystemClient("data-lake-file-system");
Retrieve those resources like this:
private readonly DataLakeServiceClient _serviceClient;
private readonly DataLakeFileSystemClient _fileSystemClient;
public ProductsController(DataLakeServiceClient serviceClient, DataLakeFileSystemClient fileSystemClient)
{
_serviceClient = serviceClient;
_fileSystemClient = fileSystemClient;
}
The integration automatically provisions the necessary Azure resources and injects them into your services. No manual connection string management, no credential hunting — Aspire handles it.
Quality-of-life improvements
Beyond the headline features, this release includes refinements that make existing database integrations more robust and developer-friendly.
MongoDB connection string fix
MongoDB connections now correctly prepend the forward slash to the database name in the connection string. This fixes an edge case that could cause connection failures in specific setups. If you’ve worked around this issue before, you can remove that workaround in Aspire 13.2.
SQL Server exports
The latest Aspire.Hosting.SqlServer package exports additional server configuration options, to give you finer-grained control over how Aspire provisions and configures SQL Server containers in your AppHost.
var sql = builder.AddSqlServer("sql")
.WithImage("mcr.microsoft.com/mssql/server", "2022-latest")
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);
var myappdb = sql.AddDatabase("myapp");
Emulator updates and security enhancements
We’ve bumped the Azure ServiceBus emulator to 2.0.0 and App Configuration emulator to 1.0.2, which bring the latest stability and feature improvements. CosmosDB’s preview emulator now includes a readiness check — no more guessing whether your emulator is actually ready to handle requests.
Azure Managed Redis switched to rediss:// (Redis Secure) as the default scheme, so your Redis connection is encrypted out of the box.
Why this matters
These are incremental changes to Aspire’s already broad database feature set, but if you’re the developer who needs to use MongoDB with EF Core in your Aspire application or you have a data lake and want to include analysis from it to drive productivity, they’ll make a huge difference. They might also make you consider new data features, which may now be much easier to implement.
Read the Aspire 13.2 release notes for more info on new and improved integrations.
Get started
Upgrade to Aspire 13.2 and try the new integrations in your next project. The aspire add command will scaffold everything you need. Start with MongoDB EF Core if you’re modernizing your data layer, or explore Azure Data Lake Storage if you’re building data-intensive workloads.
You deserve data access to be this easy and well-managed.
Get involved
- 📖 Learn more: Read the full documentation on Aspire integrations at aspire.dev.
- 💬 Give us feedback: We’d love to hear what you think — file issues or join discussions on the Aspire GitHub repo.
- 🌐 Join the community: Follow us and connect with other Aspire developers at aspire.dev/community.
0 comments
Be the first to start the discussion.