title: T4 - Entity Framework Error: Method not found: 'System.Data.Entity.DbSet`1
body: <p>Trying to create a fairly simple T4 which I'm trying to load some values that I can use for later:</p>
  
  <pre><code>&lt;#@ template debug="false" hostspecific="false" language="C#" #&gt;
  &lt;#@ assembly name="System.Core" #&gt;
  &lt;#@ assembly name="c:\users\&lt;username&gt;\documents\visual studio 2015\Projects\2_DataModelGenerator\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll" #&gt;
  &lt;#@ assembly name="c:\users\&lt;username&gt;\documents\visual studio 2015\Projects\2_DataModelGenerator\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll" #&gt;
  &lt;#@ assembly name="c:\users\&lt;username&gt;\documents\visual studio 2015\Projects\2_DataModelGenerator\2_Data\bin\Debug\2_Data.dll" #&gt;
  
  &lt;#@ import namespace="System.Linq" #&gt;
  &lt;#@ import namespace="System.Text" #&gt;
  &lt;#@ import namespace="System.Data" #&gt;
  &lt;#@ import namespace="System.Collections.Generic" #&gt;
  &lt;#@ import namespace="2_Data" #&gt;
  
  &lt;#@ output extension=".cs" #&gt;
  
  &lt;#
      DevEntities dbContext = new DevEntities();
  
              var labelClassNames = (from sd in dbContext.tblDatas
                                     where sd.SID == 155
                                     select new
                                     {
                                         SID = sd.SID.ToString(),
                                         SValue = sd.SValue.ToString()
                                     }).ToList();
  
  #&gt;
  </code></pre>
  
  <p>When I save the T4 I get this error:</p>
  
  <blockquote>
    <p>Error Running transformation: System.MissingMethodException: Method
    not found: 'System.Data.Entity.DbSet`1&lt;2_Data.tblData>
    2_Data.DevEntities.get_tblDatas()'</p>
  </blockquote>
  
  <p>I have tested this code in another solution (using EF 6.1.3) and it works without issue (loads data into <code>var labelClassNames</code>).  Seems to be an issue only in T4 template.</p>
  
  <p>Do I need to import another namespace?  I'm not sure what I'm missing!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>In my TT code:</p>
  
  <pre><code>        dbc context = new dbc();
          DevEntities mdc = new DevEntities();
          mdc = context.returnContext();
  </code></pre>
  
  <p>Added a class in my class library:</p>
  
  <pre><code>public class dbc
  {
      private DevEntities dbContext;
      public dbc()
      {
          dbContext = new DevEntities();
      }
      public DevEntities returnContext()
      {
          return dbContext;
      }
  }
  </code></pre>
  
  <p>Same error as before:</p>
  
  <blockquote>
    <p>Running transformation: System.MissingMethodException: Method not
    found: 'System.Data.Entity.DbSet</p>
  </blockquote>
  
  <p>However, when I debug the t4 template I get a different message:</p>
  
  <blockquote>
    <p>No connection string named 'DevEntities' could be found in the
    application config file.</p>
  </blockquote>
  
  <p>However, I have copied the App.config file from my class library that include the .edmx file down to my project that contains the .tt file</p>
  
  <p>Any ideas?</p>