title: Call stored procedure using ExecuteSqlCommand (expects parameters which was not supplied)
body: <p>I'm trying to call a stored procedure from EF using <code>context.Database.ExecuteSqlCommand</code> since one of my parameters is a datatable.</p>
  
  <p>Here are the procedure's parameters :</p>
  
  <pre><code>ALTER PROCEDURE [mySchema].[myProc]
      @customerId INT,
      @indicatorTypeId INT,
      @indicators [mySchema].[IndicatorList] READONLY,
      @startDate DATETIME,
      @endDate DATETIME
  </code></pre>
  
  <p>and here is the c# code calling the stored procedure :</p>
  
  <pre><code>var indicatorsDt = new DataTable();
  
  indicatorsDt.Columns.Add("Date", typeof(DateTime));
  indicatorsDt.Columns.Add("Ongoing", typeof(int));
  indicatorsDt.Columns.Add("Success", typeof(int));
  indicatorsDt.Columns.Add("Warning", typeof(int));
  indicatorsDt.Columns.Add("Error", typeof(int));
  indicatorsDt.Columns.Add("Other", typeof(int));
  
  var customerIdParam = new SqlParameter("customerId", SqlDbType.Int);
  customerIdParam.Value = customerId;
  
  var typeIdParam = new SqlParameter("indicatorTypeId", SqlDbType.Int);
  typeIdParam.Value = typeId;
  
  var startDateParam = new SqlParameter("startDate", SqlDbType.DateTime);
  startDateParam.Value = startDate;
  
  var endDateParam = new SqlParameter("endDate", SqlDbType.DateTime);
  endDateParam.Value = endDate;
  
  foreach (var indicator in indicators)
  {
      indicatorsDt.Rows.Add(indicator.Date, indicator.Ongoing, 
                            indicator.Success, indicator.Warning, 
                            indicator.Error, indicator.Other);
  }
  
  var tableParameter = new SqlParameter("indicators", SqlDbType.Structured);
  tableParameter.Value = indicatorsDt;
  tableParameter.TypeName = "MySchema.IndicatorList";
  
  context.Database.ExecuteSqlCommand("exec MySchema.MyProc", customerIdParam, typeIdParam, tableParameter, startDateParam, endDateParam);
  </code></pre>
  
  <p>As you can see, all parameters are provided, none of them has a null value but I always get this <code>SqlException</code> :</p>
  
  <blockquote>
    <p>Procedure or function 'UpdateIndicators' expects parameter
    '@customerId', which was not supplied.</p>
  </blockquote>
  
  <p>I can't figure out what I am missing. Is the use of <code>SqlParameter</code> wrong ? Parameters are supplied in the same order in the <code>ExecuteSqlCommand</code> even if it is not important.</p>
  
  <p>Thank in advance.</p>