microsoft / microsoft/aspire

Add DbContextOptions lifetime configuration support to Aspire.Microsoft.EntityFrameworkCore.SqlServer

Open
#13,350 1 comment 0 reactions 0 assignees View on GitHub
area-integrations
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I am trying to leverage Aspire to build out a development environment to test the [WolverineFx](https://wolverinefx.net/guide/durability/efcore/#getting-started) framework.

It recommends (see link) to use the Singleton ServiceLifetime for DbContextOptions for performance benefits.

Using the provided API from [Aspire.Microsoft.EntityFrameworkCore.SqlServer](https://github.com/dotnet/aspire/tree/main/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer), this does not seem possible.

### Describe the solution you'd like

I would love to be able to provide the lifetime options for the DbContext options into the registration extension method.

One of the benefits of the client aspire library is being able to just leverage the name of the Resource from the AppHost for service discovery. An alternative solution would be to use the base .UseSqlServer extension method overload and find the connection string manually. I don't immediately know the conventions by which Aspire creates those connection strings, which makes this options (although functional), slightly more difficult than the other.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer and inspect the registration extension method linked in the issue. Determine how lifetime options could be exposed while preserving Aspire resource-name connection string discovery, then verify the behavior with the component's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.