In .NET Aspire, how can I model/configure multiple connection strings to the same database? In the example below, I want MigrationService
to connect to the same db
database but using a different connection string than ApiService
in order to implement principal of least privilege (only use db_ddladmin
for applying EF Core migrations).
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddSqlServer("sql")
.PublishAsConnectionString()
.AddDatabase("db");
builder.AddProject<Projects.Parameters__MigrationService>("migrationservice")
.WithReference(db);
builder.AddProject<Projects.Parameters_ApiService>("api")
.WithReference(db);
builder.Build().Run();