1

We're working on an ASP.NET Core application using Dependency Injection and Entity Framework 6, and we are discussing with my team about database performance. We use Prefix for monitoring our application, and we detect that EF6 opens and close the connection each time it made a request. This is fine regarding to the Entity Framework principle, but if we send a lots of request (30 requests), just SELECT requests, it opens / closes the connection at each request.

enter image description here

As you can see, the open / close operation takes for each request 43ms, and that can be annoying. The code which made the request uses a single instance of Dbcontext for the HTTP request.

We tried to create, of ourself, an unique connection for each request, open it and close it at the very end of the HTTP request. So we have an unique Open and an unique Close from each HTTP request, but we detect bad performance from .NET code this time, but from unknown source (maybe EF6 ?)

enter image description here

Now we are a little bit lost with that performance question. What is the better ? Is that the correct way of using EF6 ?

Christophe Gigax
  • 2,511
  • 4
  • 21
  • 36

0 Answers0