Connection pool exhaustion in EFCore provider
Posted: Tue 05 Mar 2019 10:36
The EFCore provider doesn't close connections when the DbContext is disposed in combination with an ambient TransactionScope as discussed here.
Result is that DbConnections are never returned to the connection pool causing connection pool exhaustion.
Situation when disposing the DbContext with Devart.Data.Oracle.EFCore:

Situation when disposing the DbContext with Microsoft.EntityFrameworkCore.SqlServer:

Can you confirm this is a bug?
Sample code:
Result is that DbConnections are never returned to the connection pool causing connection pool exhaustion.
Situation when disposing the DbContext with Devart.Data.Oracle.EFCore:

Situation when disposing the DbContext with Microsoft.EntityFrameworkCore.SqlServer:

Can you confirm this is a bug?
Sample code:
Code: Select all
using (var scope = new TransactionScope(
TransactionScopeOption.Required,
new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted},
TransactionScopeAsyncFlowOption.Enabled))
{
using (var context = new BloggingContext())
{
var blog = new Blog
{
Url = "http://www.foo.bar",
Posts = new List<Post>
{
new Post {Title = "Test", Content = "The content"}
}
};
context.Add(blog);
context.SaveChanges();
scope.Complete();
} // <-- DbConnection is never closed and returned to the connection pool when BloggingContext gets disposed
}