Skip to content

Instantly share code, notes, and snippets.

@ZephiroRB
Created March 1, 2022 16:47
Show Gist options
  • Save ZephiroRB/d6d22eafe7581d39b24d1de970750d41 to your computer and use it in GitHub Desktop.
Save ZephiroRB/d6d22eafe7581d39b24d1de970750d41 to your computer and use it in GitHub Desktop.
Soporte para Resolvers
builder.Services.AddDbContextFactory<TemplateContext>(opt => {
var dbHost = Environment.GetEnvironmentVariable("DB_HOST");
var dbPort = Environment.GetEnvironmentVariable("DB_PORT");
var dbUser = Environment.GetEnvironmentVariable("DATABASE_USER");
var dbPassword = Environment.GetEnvironmentVariable("DATABASE_PASSWORD");
var dbName = Environment.GetEnvironmentVariable("DB_NAME");
var connectionString = $"Server={dbHost};port={dbPort};user id={dbUser};password={dbPassword};database={dbName};pooling=true";
opt.UseNpgsql(connectionString);
});
builder.Services.AddScoped<TemplateContext>(
sp => sp.GetRequiredService<IDbContextFactory<TemplateContext>>()
.CreateDbContext());
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment