title: How to use prepared statement using entity framework with MYSQL DB?
body: <p>I have been trying to incorporate prepared statements into my application which is using EF 5.0. Kindly look at my script below.</p>
  
  <pre><code>int parameterValue = 100000;
  var addParameters = new List&lt;MySqlParameter&gt;();
  var param1 = new MySqlParameter();
  param1.Direction = System.Data.ParameterDirection.Input;
  param1.Value = parameterValue;
  param1.ParameterName = "user_id";
  addParameters.Add(param1);
  db.Database.ExecuteSqlCommand(@"delete FROM tbl_user where user_id = @user_id", addParameters);
  </code></pre>
  
  <p>it produces this error</p>
  
  <pre><code>Exception: {"Fatal error encountered during command execution."}
  InnerException: {"Parameter '@user_id' must be defined."}
  </code></pre>
  
  <p>so based on InnerException description i changed the parameter nae to "@user_id"</p>
  
  <pre><code>int parameterValue = 100000;
  var addParameters = new List&lt;MySqlParameter&gt;();
  var param1 = new MySqlParameter();
  param1.Direction = System.Data.ParameterDirection.Input;
  param1.Value = parameterValue;
  param1.ParameterName = "@user_id";
  addParameters.Add(param1);
  db.Database.ExecuteSqlCommand(@"delete FROM tbl_user where user_id = @user_id", addParameters);
  </code></pre>
  
  <p>but still the same error.</p>
  
  <p>What could i be doing wrong?</p>
  
  <p>Thanks in advance.</p>
  
  <p>==============================================
  Additional info</p>
  
  <pre><code>&lt;package id="EntityFramework" version="5.0.0" targetFramework="net40" /&gt;
  &lt;package id="MySql.Data" version="6.7.4" targetFramework="net40" /&gt;
  &lt;package id="MySQL.Data.Entities" version="6.7.4.1" targetFramework="net40" /&gt;
  </code></pre>