title: The SqlParameterCollection only accepts non-null Parameter type objects
body: <p>I am trying to use stored procedures in Entity Framework Core. When executing a stored procedure, I am passing two input parameters and one output parameter. I keep getting this error:</p>
  
  <blockquote>
    <p>The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects.</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>public string InsertCardsData(DateTime RecordingStartDate, DateTime RecordingEndDate)
  {
          try
          {
              // DateTime DRecEndDate = Convert.ToDateTime(RecordingEndDate);
              DateTime DRecEndDate = RecordingEndDate.AddDays(1);
  
              var RecordStartDate = new SqlParameter
              {
                  ParameterName = "RecordingStartDate",
                  Value = RecordingStartDate,
                  Direction = ParameterDirection.Input
              };
  
              var RecordEndDate = new SqlParameter
              {
                  ParameterName = "RecordingEndDate",
                  Value = DRecEndDate,
                  Direction = ParameterDirection.Input
              };
  
              var RecordCount = new SqlParameter
              {
                  ParameterName = "RecLoadCount",
                  Direction = ParameterDirection.Output
              };
  
              var SQL = "Exec Recload_InsertPrimeExtract @RecordingStartDate, @RecordingEndDate, @RecLoadCount OUT";
              var result = _context.Database.ExecuteSqlRaw(SQL, RecordStartDate, RecordEndDate, RecordCount);
              var RecordCountValue = RecordCount.Value.ToString();
  
              return RecordCountValue;
          }
          catch (Exception ex)
          {
              return "";
          }
  }
  </code></pre>
  
  <p>I will put a a meaningful catch statement, but right now, I am putting a breakpoints in catch statement and the above error occurs.</p>
  
  <p>Any help will be highly appreciated.</p>