title: Cannot Pass Parameter in DbCommand in Entity Framework
body: <p>I have error when I try to pass parameter to stored procedure using DbCommand</p>
  
  <p>Error returned: </p>
  
  <blockquote>
    <p>Procedure or function 'Procedure_Name' expects parameter '@TEID', which was not supplied.</p>
  </blockquote>
  
  <p>These are my procedure parameters: </p>
  
  <pre><code>@PageNumber INT = 1,
  @PageSize INT = 50,
  @StartTime nvarchar(max) = -1 ,
  @EndTime nvarchar(max) = -1 ,
  @Month NVARCHAR(2) = -1,
  @Year NVARCHAR(4) = -1,
  @Day NVARCHAR(2) = -1,
  @Hour NVARCHAR(2)=-1,
  @TEID nvarchar(max) ,
  @IgnoreIdlingTime int=120,
  @DrivingTime int=300,--5 minutes by default
  @CalculationFactor nvarchar(10)='speed'
  </code></pre>
  
  <p>My code to execute procedure and  pass parameters: </p>
  
  <pre><code>using (var context = new GPSModel())
  {
      context.Database.Initialize(force: false);
  
      // Create a SQL command to execute the stored procedure
      var cmd = context.Database.Connection.CreateCommand();
      cmd.CommandText = "Procedure_Name";
  
      DbParameter TEIDParam = cmd.CreateParameter();
      TEIDParam.ParameterName = "@TEID";
      TEIDParam.DbType = System.Data.DbType.String;
      TEIDParam.Direction = ParameterDirection.Input;
      TEIDParam.Value = TEID;
      cmd.Parameters.Add(TEIDParam);
  
      context.Database.Connection.Open();
  
      var reader = cmd.ExecuteReader();
  }
  </code></pre>
  
  <p>I tried to remove <code>@</code> sign and send <code>SqlParameter</code> instead of <code>DbParameter</code> but still I have the same issue.</p>
  
  <p>Is there any other way to do that where my stored procedure is very complex and contains multi sets</p>
  
  <p>Thanks...</p>