title: entity framework 4 POCO's stored procedure error - "The FunctionImport could not be found in the container"
body: <p>Entity Framework with POCO Entities generated by T4 template.  Added Function Import named it "procFindNumber" specified complex collection named it "NumberResult".</p>
  
  <p>Here's what got generated in Context.cs file:</p>
  
  <pre><code>public ObjectResult&lt;NumberResult&gt; procFindNumber(string lookupvalue)
  {
     ObjectParameter lookupvalueParameter;
  
     if (lookupvalue != null)
     {
        lookupvalueParameter = new ObjectParameter("lookupvalue", lookupvalue);
     }
     else
     {
         lookupvalueParameter = new ObjectParameter("lookupvalue", typeof(string));
     }
     return base.ExecuteFunction&lt;NumberResult&gt;("procFindNumber", lookupvalueParameter);
  }
  </code></pre>
  
  <p>Here's the stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[procFindNumber] 
  @lookupvalue varchar(255)   
  AS
  BEGIN
  SET NOCOUNT ON;    
  DECLARE @sql nvarchar(MAX); 
  
  IF @lookupvalue IS NOT NULL AND @lookupvalue &lt;&gt; ''
      BEGIN                   
          SELECT @sql = 'SELECT dbo.HBM_CLIENT.CLIENT_CODE, dbo.HBM_MATTER.MATTER_NAME, dbo.HBM_MATTER.CLIENT_MAT_NAME 
                  FROM dbo.HBM_MATTER INNER JOIN dbo.HBM_CLIENT ON dbo.HBM_MATTER.CLIENT_CODE = dbo.HBM_CLIENT.CLIENT_CODE 
                  LEFT OUTER JOIN dbo.HBL_CLNT_CAT ON dbo.HBM_CLIENT.CLNT_CAT_CODE = dbo.HBL_CLNT_CAT.CLNT_CAT_CODE 
                  LEFT OUTER JOIN dbo.HBL_CLNT_TYPE ON dbo.HBM_CLIENT.CLNT_TYPE_CODE = dbo.HBL_CLNT_TYPE.CLNT_TYPE_CODE 
                  WHERE (LTRIM(RTRIM(dbo.HBM_MATTER.CLIENT_CODE)) &lt;&gt; '''')'
          SELECT @sql = @sql + ' AND (dbo.HBM_MATTER.MATTER_NAME like ''%' + @lookupvalue + '%'')'
          SELECT @sql = @sql + ' OR (dbo.HBM_MATTER.CLIENT_MAT_NAME like ''%' + @lookupvalue + '%'')'
          SELECT @sql = @sql + ' ORDER BY dbo.HBM_MATTER.MATTER_NAME'
          -- Execute the SQL query
          EXEC sp_executesql @sql
      END 
  END
  </code></pre>
  
  <p>In my WCF service I try to execute the stored procedure:</p>
  
  <pre><code>[WebGet(UriTemplate = "number/{value}/?format={format}")]        
  public IEnumerable&lt;NumberResult&gt; GetNumber(string value, string format)
  {
     if (string.Equals("json", format, StringComparison.OrdinalIgnoreCase))
     {
         WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;
     }
  
     using (var ctx = new MyEntities())
     {                
         ctx.ContextOptions.ProxyCreationEnabled = false;
         var results = ctx.procFindNumber(value);
         return results.ToList();
     }
  }
  </code></pre>
  
  <p>Error message says "The FunctionImport ... could not be found in the container ..."</p>
  
  <p>What am I doing wrong?  </p>