-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Allow named in-memory stores #3253
Comments
At the moment, do you get one per ServiceProvider, or one per context type per ServiceProvider? Either way, I don't think we need the named database capability for RC. |
You get one table per entity type per service provider. |
Reactivating (presumably for the backlog) as I am writing the docs for in-memory testing and this is not very easy at the moment. I think named instances could be a good solution to avoid folks having to muck around with ServiceCollections. |
Issue #3253 Makes it easier to write isolated tests while still sharing a service provider between tests.
Issue #3253 Makes it easier to write isolated tests while still sharing a service provider between tests.
Issue #3253 Makes it easier to write isolated tests while still sharing a service provider between tests.
Sorry for bringing up an old thread, but currently the Testing with InMemory in the EF docs:
Now 1.0.0 is released and I assume this warning in the docs not required anymore, and a ServiceCollection is no longer required to instantiate an in-memory context I'm assuming the simplest way to instantiate an in-memory context now is:
|
@NeilCross opened dotnet/EntityFramework.Docs#287 to fix the docs. The docs are currently migrating to a new system, so I'll fix once the migration is done. |
Good to know, thanks Rowan. |
Following code works perfectly for me, |
@logamanig It's generally best to avoid calling |
without calling UseInternalServiceProvider, not able to isolate the InMemoryDatabase instance between test cases. Just a unique database name is not enough to isolate. |
@logamanig There are other ways to deal with that that aren't such a heavy hammer:
Also, in 3.0 is is less likely you will run into this case at all. |
Thanks @ajcvickers !
|
We decided in API review to remove the "persist" flag from the in-memory provider and replace with a string that could be used to create a named in-memory store. However, we were pretty much never using the persist: false anyway, so I just removed it and created a bug to triage adding named databases so we could triage appropriately.
The text was updated successfully, but these errors were encountered: