UseEntityFramework dynamic DbContext per request #691
-
Hi, when using EF to store logs, is it possible to resolve the connection string per request? Audit.Core.Configuration.Setup()
.UseEntityFramework(x =>
x.UseDbContext(<resolved_connectionstring>) Similar to this below? Thanks services.AddDbContext<ApplicationDbContext>((sp, options) =>
{
var connectionString = sp.GetRequiredService<Resolver>().GetConnectionString();
options.UseSqlServer(connectionString);
}); |
Beta Was this translation helpful? Give feedback.
Answered by
thepirat000
Aug 29, 2024
Replies: 1 comment
-
Assuming you're using EF Core, you could do something like this; Audit.Core.Configuration.Setup()
.UseEntityFramework(cfg => cfg
.UseDbContext(efEvent => efEvent.GetEntityFrameworkEvent().GetDbContext().GetService<ApplicationDbContext>())); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
outomator
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming you're using EF Core, you could do something like this;