title: Entity Framework Power Tools Beta 3 throws exception "sequence contains no matching element" when trying to generate views
body: <p><strong>Struggling to create Entity Framework precompiled views for database and need help.</strong></p>
  
  <p>While using Visual Studio 2010, I have been unable to generate precompiled views using latest version of the Entity Framework Power Tools Beta 3.  When I right mouse click on the dbContext based file and select "Generate Views" option, it pops up a "Sequence contains no matching element" dialog error box.</p>
  
  <p>Uninstalling the power tools extension, rebooting Visual Studio and computer has not helped.</p>
  
  <p><strong>Question 1:  What could be causing this error.  Entity Framework Power Tools is worthless until I can get it working?</strong></p>
  
  <p>So up until now the only way I'm able to generate views for this sequence is by using a T4 template (from Internet) but it often times-out and fails to complete.  The database has about 350 tables and the number of views it creates is about 670 views.  However, it fails to create the views the majority of the time and I have to repeatedly try and sometimes shut down and reboot to get it to work.  CPU  utilization during this time is about 12% on an i7 Quad core with SSD and 8GB of memory so it's strange.  However when the views are generated (no timeout) they work fine.</p>
  
  <p><strong>Question 2:  Is there anything that can be done to keep this template from timing-out and failing?</strong></p>
  
  <p>Now unable to just give up I've looked into trying other ways, I was able to generate the views by creating a database first project and adding an Entity Framework Data Model created from an existing database.  The model is created fine and I'm able to create the views as expected but they are not recognized when placed in the final assembly and entity tries to query the database.  When placing in the assembly I replaced the view file that works when generated using T4 template the file created by the Power Tools context menu.</p>
  
  <p><strong>Is the namespace causing this problem?</strong></p>
  
  <p>I think it has something to do with the namespace but I don't know the rules on how it finds out the compiled views and what does the namespace and views have to be called in order to be found and used.  The views created from the DbContext file is in a different project than the views created using the Edmx model of the same database.  I have a DbContext project a Model Project a Domain Classes project and Domain Class Mapping project.  I place the views file in the same assembly (project) as the Domain Classes.</p>
  
  <p>Here is an example of the generated view output.  The one on the left was created using a T4 template and "Run Custom Tool"  and the one on the right was created with Entity Framework Power Tools Beta 3 and selecting "Create Views" from context menu while cursor on the EDMX file.</p>
  
  <p><strong>Working one:</strong></p>
  
  <pre><code>SELECT VALUE [xxx.yyy.Provider.DataContext.RouteStop](T1.RouteStop_RouteStopId, ...
  FROM (
       SELECT   T1.RouteStopId as RouteStop_RouteStopId, .....
       FROM     CodeFirstDatabase.RouteStop AS T
       ) AS T1
  </code></pre>
  
  <p><strong>Not working one:</strong></p>
  
  <pre><code>SELECT Value [xxx.yyy.Provider.DataModel.Store.RouteStop](T1.RouteStop_RouteStopId, ...
  FROM (
       SELECT   T1.RouteStopId as RouteStop_RouteStopId, .....
       FROM     ZeeZorProviderEdmx.RouteStops AS T
       ) AS T1
  </code></pre>
  
  <p>The namespace for the project that contains the Domain classes and also contains a copy of the generated views is "xxx.yyy.Provider.DomainClasses" if that helps.</p>
  
  <p><strong>Question 3:  How do I get the Power Tools generated views from EDMX working like the other view files create from T4 Template.</strong></p>
  
  <p>I've been losing hear over this and I don't have much left anyway so I could really use some good advice.  I need a solution and I see one of 3 ways:</p>
  
  <ol>
  <li><p>Use Entity Framework Power Tools Beta 3 and the "Create Views"
  context menu option when DbContext based object file is selected.</p></li>
  <li><p>Use the T4 template and just grin and bear the timeout issues and
  constant failures when building the views.</p></li>
  <li><p>Use the Model project with EDMX file and use the Power Tools Beta 3
  "Create Views" context menu and solve the namespace or view
  discovery issue.</p></li>
  </ol>
  
  <p>Please help me figure out one of these 3 ways and get it working.</p>
  
  <p>Thanks,
  Blake</p>