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

Configure run-time parameters in the connection string #2117

Open
austindrenski opened this Issue Aug 16, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@austindrenski
Member

austindrenski commented Aug 16, 2018

moved from npgsql/Npgsql.EntityFrameworkCore.PostgreSQL#603

@austindrenski wrote:

Does EF Core provide any hooks to set a run-time configuration parameter for each query on a DbContext?

For example, if I want to increase the work_mem for a given DbContext, I can do this, but the session is reset by the next query:

// returns 512MB
ctx.Database.ExecuteSqlCommand("SET work_mem = '512MB'; SHOW work_mem;");

// returns default value
ctx.Database.ExecuteSqlCommand("SHOW work_mem;");

What I'm imagining is something along the lines of a global query filter.

@roji Do you know of any way to do this?

@roji wrote:

There's nothing like this in EF Core as far as I'm aware...

We could look at it at the ADO level, via the connection string - that would have the advantage of sending the value in the PostgreSQL startup packet, which would naturally make it persist across connection resets etc... This would have to be checked though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment