Search code examples
network-programmingado.netentity-framework-coressmsdatabase-performance

C# .NET Core EF or ADO.NET query takes minutes and SSMS just 30 seconds, why?


So yeah, I'm currently stuck on a simple code that my app should do pretty quickly, considering the same query runs in SSMS in about 34 seconds and uses around 90mbps:

enter image description here

But then, look at what EF does while running the same query:

enter image description here

Not even using ADO.NET makes it go as fast as SSMS. What gives? I've yet to try this with .NET Framework. Currently using .NET Core 3.1. Is this a bug?

Any pointers are greatly welcome, thanks in advance!


Solution

  • For those who encounter the same issue as me: The issue was because I was (rightfully) using MultipleActiveResultSets=true. Turns out I'd have to disable it for this specific bit of code, then I can resume using it. Thanks to @Reza on https://stackoverflow.com/a/51824444/1598811 for that suggestion :)