Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve connection names for readability #2165

Open
killnine opened this issue Nov 27, 2024 · 1 comment
Open

Improve connection names for readability #2165

killnine opened this issue Nov 27, 2024 · 1 comment

Comments

@killnine
Copy link

killnine commented Nov 27, 2024

Type of issue

Other (describe below)

Description

In the Example Usage section of the EF Core page, the integration-consuming project gets an example:

builder.AddSqlServerDbContext<YourDbContext>("sqldb")

This is a very concise description. However, look at it in conjunction with the App Host project configuration of the database:

var builder = DistributedApplication.CreateBuilder(args);

var sql = builder.AddSqlServer("sql")
                 .WithLifetime(ContainerLifetime.Persistent);

var db = sql.AddDatabase("database");

builder.AddProject<Projects.ExampleProject>()
       .WithReference(db);

// After adding all resources, run the app...

In this example, "database" and "sqldb" could be named the same thing to convey the fact that how the hosting integration names the database must match how the client integration names the database as well.

This point is covered well in this community video by Codewrinkles

My recommendation is:

builder.AddSqlServerDbContext<YourDbContext>("sqldb")
var builder = DistributedApplication.CreateBuilder(args);

var sql = builder.AddSqlServer("sqlserver")
                 .WithLifetime(ContainerLifetime.Persistent);

var db = sql.AddDatabase("sqldb");

builder.AddProject<Projects.ExampleProject>()
       .WithReference(db);

// After adding all resources, run the app...

Page URL

https://learn.microsoft.com/en-us/dotnet/aspire/database/sql-server-entity-framework-integration?tabs=dotnet-cli%2Cssms

Content source URL

https://github.com/dotnet/docs-aspire/blob/main/docs/database/sql-server-entity-framework-integration.md

Document Version Independent Id

bf3e4e4b-039e-29fa-f9f0-3512be634ca8

Article author

@CamSoper

@davidfowl
Copy link
Member

cc @IEvangelist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants