Skip to content
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

API for fully resetting a DbContext (ResetState) #23115

Closed
roji opened this issue Oct 28, 2020 · 3 comments
Closed

API for fully resetting a DbContext (ResetState) #23115

roji opened this issue Oct 28, 2020 · 3 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.

Comments

@roji
Copy link
Member

roji commented Oct 28, 2020

#15577 added ChangeTracker.Clear, which is a faster alternative to mass-detach. However, this is not a full context reset, in the way that DbContext pooling works (ResetState) - other services other than the ChangeTracker aren't reset by this. The main problem with using calling ResetState on a context today, is that this sets _isDisposed to true, and the only way to undispose it goes through DbContextLease which is internal.

I'm noting that DbContext.Reset resets all the InternalDbSets, i.e. the local view, which has some state. Is it OK that we're telling users to reset the ChangeTracker but leaving the local view state untouched?

/cc @ajcvickers

@ajcvickers
Copy link
Contributor

@roji This was an intentional choice when implementing #15577. I started with the idea of it being a general reset, but it seemed that most people don't really want that. For example, I don't think people will expect (or even want) options they have changed on the context to be reset. Likewise with registered events.

I think we could consider doing a full reset (this issue), but I was planning on basing that on feedback.

@roji
Copy link
Member Author

roji commented Oct 28, 2020

OK. Are we sure there's no bug lurking in the fact that we reset the state manager but not the local view? If not then this is indeed just another possible enhancement for the backlog...

@ajcvickers
Copy link
Contributor

@roji I wrote a bunch of tests. :-) I think its better to think of it not as resetting the state manager, but really just clearing out all tracked entities, as the API name suggests.

@ajcvickers ajcvickers added this to the Backlog milestone Oct 30, 2020
@ajcvickers ajcvickers removed this from the Backlog milestone Nov 10, 2021
@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Mar 10, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.
Projects
None yet
Development

No branches or pull requests

2 participants