EF6/Code First: Super slow during the 1st query, but only in Debug

I’m using EF6 rc1 with Code First strategy, without precompiled views and the problem is: If I compile and run the exe application it takes like 15 seconds to run the first query (that’s okay, since I’m still working on the pre-generated views). But if I use Visual Studio 2013 Preview to Debug the exact same application it takes almost 2 minutes BEFORE running the first query:

Dim Context = New MyEntities()
Dim Query = From I in Context.Itens '' <--- The debug takes 2 minutes in here
Dim Item = Query.FirstOrDefault()

Is there a way to remove this extra time? Am I doing something wrong here?

Ps.: The context itself is not complicated, its just full with 200+ tables.

Edit: Found out that the problem is that during debug time the EF appears to be generating the Views ignoring the pre-generated ones. Using the source code from EF I discovered that the property:

IQueryProvider IQueryable.Provider
            return _provider ?? (_provider = new DbQueryProvider(

is where the time is being consumed. But this is strange since it only takes time in debug. Am I missing something here?

Edit: Found more info related to the question: Using the Process Monitor (by Sysinternals) I found out that there its the ‘desenv.exe’ process that is consuming tons of time. To be more specific its consuming time with an ‘Thread Exit’. It repeats the Thread Exit stack 36 times. I don’t know if this info is very useful, but I saved a ‘.cvs’ with the stack, here is his body: […] (edit: removed the ‘.cvs’ body, I can post it again by the comments if someone really think its going to be useful, but it was confusing and too big.)

Edit: Installed VS2013 Ultimate and Entity Framework 6 RTM. Installed the Entity Framework Power Tools Beta 4 and used it to generate the Views. Nothing changed… If I run the exe it takes 20 seconds, if I ‘Start’ debugging it takes 120 seconds.

Edit: Created a small project to simulate the error: http://sdrv.ms/16pH9Vm Just run the project inside the environment and directly through the .exe, click the button and compare the loading time.

MySql Query Super Slow

I have the following query which is super slow (taking 4-5 seconds just for the results. I was wondering if anyone could see anything that I could do differently with this query to speed it up? Thanks

Extremely slow query on 1st run, even with indexes

I have an extremely slow query that is slow despite indexes being used(on the order of 1-3 minutes). Similar queries will be run 4-6 times by the user, so speed is critical. QUERY: SELECT SUM(bh.cou

EF Saving only the 1st child entitty

Please look at the following I’m trying to save and Event and EventDetails corresponding to that event. It’s saving the Event and the 1st EventDetail from the loop Thanks for your help. public class E

JOIN query only returning 1st row

I’m trying to retrieve multiple rows from joining two tables where store.itemid = item_list.id. $query = SELECT s.price, il.* FROM store s LEFT JOIN item_list il ON s.itemid = il.id; I then have:

Access exports only 1st column of query

All – I’m embarrassed to ask something that appears to be so rudimentary, but I’m stuck. Using Access 2007, I ran a query against a single 84K row table to produce a result set of ~80K row. I can’t c

Firefox printing only 1st page

I’m working on print friendly css for a website. It previews/prints perfectly in IE, but Firefox (version 3.6) only previews/prints the 1st page. Is anyone aware of anything that would generally cause

PSNUP, Converting 1st Page only

I am trying to use PSNUP to Shrnk my PS file but it is effective on 1st page only, and not working on o Anybody who knows may help please. MY sample File can be downloaed from :- https://www.dropbox.c

Codeigniter always only returning 1st row of the query result

Update I tried to use sizeof($result) on my controllerand the result is more than 1, so i think the mistake is somewhere on the controller. I tried to run this query : $query = SELECT * FROM `hospit

Linq query is super slow?

I copied the sql query built by linq from sql profiler here is what’s annoying about it: It prefixes select ..columnNames.. from (select ..columnNames.. from ( select cNames from view) Comments: the

Java Bubblesort is only swapping 1st array item

my bubble sort code is only swapping the 1st array item. All other items are left as 0. I think my nested loops are wrong or something I haven’t been able to diagnose it correctly yet. so here is my c


Have you tried compiling from a different machine or partition? Just a thought.

This is a known performance issue in Lazy (which EF is using) when the debugger is attached. We are currently working on a fix (the current approach we are looking at is removing the use of Lazy). We hope to ship this fix in a patch release soon. You can track progress of this issue on our CodePlex site – http://entityframework.codeplex.com/workitem/1778.

More details on the coming 6.0.2 patch release that will include a fix are here – http://blogs.msdn.com/b/adonet/archive/2013/10/31/ef6-performance-issues.aspx

I don’t know if you have found the solution. But in my case, I had similar issue which wasted me close to a week after trying different suggestions. Finally, I found a solution by changing my web.config to optimizeCompilations=”true” and performance improved dramatically from 15-30 seconds to about 2 seconds.