Exceedingly long compile time for Entity Framework

2019-09-19 03:28发布

问题:

The problem is a project that takes more that 45 seconds from the point of hitting F5 until the webpage is rendered - with the vast bulk of the time coming after:

'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/22/ROOT-1-130320809789454211): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Framework\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

and before:

'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/22/ROOT-1-130320809789454211): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

Am using VS2013 compiling a 4.5 targeted project and have seen the same behavior using EF5 thur EF6.0.3 Clean and Build time are near instantaneous.

I'm working with Code First and POCOs that were generated by the Reverse Engineer tool. Moderately complex (a couple many-to-many objects) but fairly small - less than two dozen entities.

I've twiddled with the context's configuration ProxyCreationEnabled and LazyLoadingEnabled with no effect on build time. I've removed a couple of the many-to-many relations - again, no effect.

I've loaded a couple sample EF projects to compare but I'm not seeing the System.Data.Entity.dll being used. Is that perhaps related to the db server being used by the project? Rather than using VS's LocalDb, my dev database is SQL 2012 Dev edition - just because I prefer watching/checking output with SSMS.

I've made some initial attempts at switching to LocalDb but encounter unrelated errors and the same delay at the same place. Happy to dive down that rabbit hole if it's deemed relavent.

I have little to no experience mucking about the GAC or troubleshooting the innards of the framework so if there's something to be learned about my system via deeper inspection of either, please speak slowly as if to a small child.

Thanks much

回答1:

I stepped through my web.config and found a couple sections that I'm not - after commenting them out the compile time was cut in half.