2

I just started using EF 6 and I noticed that the first execution takes more time because it needs to be compiled, so I researched and found that you can pre-generate the view.

I used EF Power Tool to generate the view: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/

It's a dll, and I'm building using the option Embed in Output Assembly.

The problem is that even though I have the view.cs when I execute the first query I have the same delay, so it seems that my library is not using the pre-generated view.

What could be wrong? I'm passing the connection to the entity using an EntityConnectionStringBuilder returning a EntityConnection object.

Also I tried changing the view.cs to Embedded Resource, since with Compile I did not have any changes, in both ways I still have the first time delay.

I'm sure I'm missing something, but not sure what.

Thanks in advance, Lucas.

Clifford
  • 88,407
  • 13
  • 85
  • 165
Lucas
  • 35
  • 5

1 Answers1

1

EF5 views will not work with EF6 (in addition to that there are some issues with EF6 Beta 1 and EF6 RC1 which prevent using views with EF6 - these issues should be fixed for EF6 RTM). I created a T4 template for generating views for EF6 - you can find more details here - again due to the problems above the views generated by the template will not work for EF6 RC1. If you absolutely think you need it you can try the version from my github - it was updated to work with EF6 RTM and also works with nightly builds. Anyways, I am pretty sure that this is actually not view generation that are causing the issues (actually the performance of view generation in EF6 has been greatly improved). We recently found a few performance issues (see 1674 and 1662) that are affecting start up time and we are looking at these.

EDIT

The version of the template that works with EF6 RTM (6.0.0.0, 6.0.1.0) has been published to the VS Gallery

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • I'm using model-first (EDMX) -- does there exist a T4 template, too? – springy76 Jan 08 '14 at 13:43
  • There is one but only for EF4/EF5 - http://visualstudiogallery.msdn.microsoft.com/a0aef503-f2b8-45ee-8770-1512ee7ee8ab. I have not gotten to create one for EF6 yet but you should be able to use EF Power Tools which can generate views for EF6 Edmx based apps. – Pawel Jan 08 '14 at 18:28
  • EF Power Tools (Beta 4) seems to be unable to work with custom providers (everything works: RunTime and Designer, but "Generate Views" fails) – springy76 Jan 09 '14 at 09:13
  • That's true - EF Power Tools 4 does not support 3rd party provider. You can try using a solution I created a few weeks ago where the views are auto-generated and saved for later use. See this http://blog.3d-logic.com/2013/12/14/using-pre-generated-views-without-having-to-pre-generate-views-ef6/ for more details. – Pawel Jan 09 '14 at 15:46