title: The data reader is incompatible with the specified model
body: <p>I am running a stored procedure by adding it in existing model (edmx) by Add--> function Import.</p>
  
  <p>I received the following error.</p>
  
  <p>The data reader is incompatible with the specified 'dbModel.stored_procedure_Result'. A member of the type, 'UID', does not have a corresponding column in the data reader with the same name.</p>
  
  <p>_Result class of the Modle is as follows</p>
  
  <pre><code>public partial class stored_procedure_Result
  {
      public int UID { get; set; }
      public int SYSTEM_ID { get; set; }
      public byte ACTIVE { get; set; }
      public string LEVEL { get; set; }
      public string SYSTEM_CODE { get; set; }
      public string SYSTEM_NAME { get; set; }
      public Nullable&lt;int&gt; SYSTEM_SUB_TYPE { get; set; }
      public Nullable&lt;int&gt; PM_ID { get; set; }
  }
  </code></pre>
  
  <p>Error occurred on the bottom line of this class</p>
  
  <pre><code>using System;
  using System.Data.Entity;
  using System.Data.Entity.Infrastructure;
  using System.Data.Entity.Core.Objects;
  using Company.Product.Domain.Models;
  
  namespace Company.Product.Domain.Data
  {
      public partial class BusinessPartnerDataContext : DbContext
      {
          public BusinessPartnerDataContext()
              : base("name=BusinessPartnerDataContext")
          {
          }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              throw new UnintentionalCodeFirstException();
          }
  
  
          public virtual ObjectResult&lt;stored_procedure_Result&gt; stored_procedure(Nullable&lt;int&gt; pCId, Nullable&lt;int&gt; pSystemId, Nullable&lt;bool&gt; pParameterShow, Nullable&lt;bool&gt; pRETActive, Nullable&lt;bool&gt; pAllLevels, Nullable&lt;bool&gt; pSystemSubTypeShow, Nullable&lt;bool&gt; pShowResultSet)
          {
              ((IObjectContextAdapter)this).ObjectContext.MetadataWorkspace.LoadFromAssembly(typeof(stored_procedure_Result).Assembly);
  
              var pCIdParameter = pCId.HasValue ?
                  new ObjectParameter("pCId", pCId) :
                  new ObjectParameter("pCId", typeof(int));
  
              var pSystemIdParameter = pSystemId.HasValue ?
                  new ObjectParameter("pSystemId", pSystemId) :
                  new ObjectParameter("pSystemId", typeof(int));
  
              var pParameterShowParameter = pParameterShow.HasValue ?
                  new ObjectParameter("pParameterShow", pParameterShow) :
                  new ObjectParameter("pParameterShow", typeof(bool));
  
              var pRETActiveParameter = pRETActive.HasValue ?
                  new ObjectParameter("pRETActive", pRETActive) :
                  new ObjectParameter("pRETActive", typeof(bool));
  
              var pAllLevelsParameter = pAllLevels.HasValue ?
                  new ObjectParameter("pAllLevels", pAllLevels) :
                  new ObjectParameter("pAllLevels", typeof(bool));
  
              var pSystemSubTypeShowParameter = pSystemSubTypeShow.HasValue ?
                  new ObjectParameter("pSystemSubTypeShow", pSystemSubTypeShow) :
                  new ObjectParameter("pSystemSubTypeShow", typeof(bool));
  
              var pShowResultSetParameter = pShowResultSet.HasValue ?
                  new ObjectParameter("pShowResultSet", pShowResultSet) :
                  new ObjectParameter("pShowResultSet", typeof(bool));
  
              return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction&lt;stored_procedure_Result&gt;("stored_procedure", pCIdParameter, pSystemIdParameter, pParameterShowParameter, pRETActiveParameter, pAllLevelsParameter, pSystemSubTypeShowParameter, pShowResultSetParameter);
          }
      }
  }
  </code></pre>
  
  <p>Sored procedure is as follows</p>
  
  <pre><code>ALTER PROCEDURE STORED_PROCEDURE 
  AS 
  DECLARE @SYSTEMS TABLE (UID int NOT NULL IDENTITY(1,1),
                          SYSTEM_ID int NOT NULL,
                          ACTIVE tinyint NOT NULL,
                          [LEVEL] char(2) NOT NULL,
                          SYSTEM_CODE char(2) NULL,
                          SYSTEM_NAME varchar(50) NULL,
                          pm_ID int NULL,SYSTEM_SUB_TYPE int NULL)
  INSERT INTO @SYSTEMS
  VALUES (1,
          62,
          1,
          'LEVEL',
          'CODE',
          'NAME')
  SELECT UID,
         SYSTEM_ID,
         ACTIVE,
         LEVEL,
         SYSTEM_CODE,
         SYSTEM_NAME
  FROM @SYSTEMS RETURN 0
  </code></pre>
  
  <p>Result of the procedure is </p>
  
  <pre><code>UID         SYSTEM_ID     ACTIVE     LEVEL      SYSTEM_CODE     SYSTEM_NAME
  
   1           62           1         LEVEL               CODE           NAME
  </code></pre>
  
  <p>Some post suggested to remove the RET statement from the stored procedure, I tried with commenting the RET statement in the stored procedure as well , but it didn’t help</p>
  
  <p>Some post suggested to check the column names, I cheked the column names in the complex type , the column names exactly matching</p>
  
  <p>Some post suggested that the all the columns which are there in the _Result class should be RETed from the procedure, but the _Result class is automatically generated, however I tried removing the last two columns as well, but it didn’t help..
  Moreover the error says ‘UID’ column, but that is present in the Procedure , procedure result, _Result class .</p>
  
  <p>I am feeling that error is in some references</p>
  
  <pre><code>using System;
  using System.Data.Entity;
  using System.Data.Entity.Infrastructure;
  using System.Data.Entity.Core.Objects;
  using Company.Product.Domain.Models;
  </code></pre>
  
  <p>as when the “Update modle from database”, it always throws error like 
  “cannot convert System.Data.Object to System.Data.Entity.Core.Objects”</p>