title: ASP.NET MVC EF Calling MySQL Stored Procedure with Out Parameters
body: <p>I am using Entity Framework ExecuteStoreQuery to call a MySql stored procedure with output parameter. The store procedure also returns a result set. </p>
  
  <p>I get the following error. </p>
  
  <p><em>OUT or INOUT argument 2 for routine mydb.mysp is not a variable or NEW pseudo-variable in BEFORE trigger</em></p>
  
  <p><strong>What is wrong? Is there a better way to call MySql sp with mix of out params and resultset?</strong></p>
  
  <p><strong>Here is the code</strong></p>
  
  <pre><code>     var outParam = new MySqlParameter();
                  outParam.ParameterName = "totalRowsOut";
                  outParam.MySqlDbType = MySqlDbType.Int64;
                  outParam.Direction = ParameterDirection.Output;
  
  var data =  db.ExecuteStoreQuery&lt;PropertySearchResultRow&gt;
  (
      "call mysp(@input1, @totalRowsOut);", 
      new MySqlParameter("input1", 10),
      outParam
  );
  
  var result = data.ToList();
  int totalRowsCount = (int)outParam.Value;
  </code></pre>