-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Using pooling for multiple DbContexts causes exception #9433
Comments
Got the same problem, using multiple DbContexts with .UseSqlServer. |
Note for people hitting this: the workaround is to not use pooling. (Pooling can give some perf improvements, but if it is so much that it is needed by your app to even function then I'd be very interested to see the numbers. We will, of course, fix this, but probably not until the 2.1 release.) |
@anpete There is a PR for this, but it looks like it needs some work. |
i had the same problem, you need to change code #9465 |
- Adds missing DbContextOptions generic parameter.
- Adds missing DbContextOptions generic parameter.
Yepper, same issue here. All same symptoms...using more than one DbContext with AddDbContextPool causes exception. |
Note for people hitting this: you should be able to workaround the issue by overriding the default DI configuration for DbContextPool to match this. |
They created wrong tests. |
@leonidmln Can you explain in some detail what is wrong with the fix? We're planning to ship this soon, so if it doesn't work, then it would be really great to find out before we ship it, but we can't see what is wrong. Can you post some code that shows what is not working? |
@ajcvickers While it does work, I believe the current fix is more like fixing the problem but not the "source" of the problem. You shouldn't even be able to throw a different kind of |
@anpete @ajcvickers Also what @leonidmln said. The tests are not correct. |
Hi @maximtarasov, @ColinRaaijmakers, @leonidmln, @paultechguy, @Megasware128. We are gathering information on the use of EF Core pre-release builds. You reported this issue shortly after the release of 2.0.0 RTM. It would be really helpful if you could let us know:
Thanks in advance for any feedback. Hopefully this will help us to increase the value of pre-release builds going forward. |
@ajcvickers Sorry for my late response. I consciously waited for the release 2.0 before testing if AddDbContextPool worked correctly because I knew it would be in 2.0 release. Assuming that this 'just' would work. Due to many different production sites, I prefer to test stable release rather than pre-builds. |
I'm getting this error too. But is not clear to me know I can take advantage of this fix. I clumsily tried to download the repo and referenced the latest Microsoft.EntityframeworkCore in my project, but ended up mired in errors. What's the recommended way to implement this fix? |
@nukuuk The fix has now been shipped yet. The easiest workaround is to use AddDbContext instead of AddDbContextPool. |
What is the easiest way to test this fix for me? |
Same here |
I was very sad to retest this issue on 2.0.1 and got the same exception. |
@oncicaradupopovici The milestone assigned at the top of the issue is the indicator of what release a fix will be in--in this case 2.1. Unfortunately, the dates for 2.1 are not confirmed yet, so I can't share them publicly at this time. |
@oncicaradupopovici yes I was disappointed to discover the same thing after installing 2.0.1 |
Anyone who is still looking at this, if you have multiple DbContext and want to implement the Pool for only one, place the DbContextPool as the last added context it appears to work and not throw the error. services.AddDbContext<ADbContext>(options => options.UseNpgsql(connectionA); );
services.AddDbContext<BDbContext>(options => options.UseNpgsql(connectionB));
services.AddDbContextPool<CDbContext>(options => options.UseNpgsql(connectionC)); Might be a useful workaround for some. |
Further technical details
EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.InMemory 2.0.0
Operating system: Mac OS X High Sierra
IDE: Rider
The text was updated successfully, but these errors were encountered: