Skip to content
Discussion options

You must be logged in to vote

Because I was interested, I build you a small sample.

This is the apphost:

var builder = DistributedApplication.CreateBuilder(args);

var pg = builder.AddPostgres("pg").WithPgAdmin();

builder.AddProject<Projects.WebApplication1>("api")
       .WithReference(pg);

builder.Build().Run();

App:

using Microsoft.EntityFrameworkCore;
using Npgsql;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<AppDbContext>();
builder.EnrichNpgsqlDbContext<AppDbContext>();

// Register the TenantContext as scoped so we can set it in the request pipeline
builder.Services.AddScoped<TenantContext>();

var app = builder.Build();

app.Use((context, next) =>
{
    var tenantId = (st…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@GioviQ
Comment options

@davidfowl
Comment options

@GioviQ
Comment options

@davidfowl
Comment options

Answer selected by davidfowl
@GioviQ
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants