title: SqlParameter vs ObjectParameter
body: <p>What is the main difference between <code>SqlParameter</code> and <code>ObjectParameter</code>?</p>
  
  <pre><code>ObjectParameter[] parameters =
  {
             new ObjectParameter("MainUserName", user.MainUserName),
             new ObjectParameter("MainUserFirstName",user.MainUserFirstName),
             new ObjectParameter("MainUserLastName",user.MainUserLastName),
             new ObjectParameter("DOJoin", DateTime.Now),
  };
  
  SqlParameter[] parameters =
         {
             new SqlParameter("@MainUserName", user.MainUserName),
  
             new SqlParameter("@MainUserFirstName",user.MainUserFirstName),
  
             new SqlParameter("@MainUserLastName",user.MainUserLastName),
  
  
  
              new SqlParameter("@DOJoin", DateTime.Now),
  
         };
  </code></pre>
  
  <p>I am working on MVC Code First, I want to make Communication with my Database through Stored procedures.
  so which one is the best approach  to passing parameters to SP?
  Last Time i tried to Execute SP by passing Sql Perameters but faced the below exception</p>
  
  <pre><code>Procedure or function 'InsertUser' expects parameter '@MainUserName', which was not supplied
  </code></pre>
  
  <p>I tried to solve it by trying different scenarios but have no luck.
  At Last I thought I should to use Object Perameters intead of Sql Perameters.
  But don't know whats the main Difference between these? </p>
  
  <p><strong>Edite</strong>
  I want to run my below code using <code>ExecuteSqlCommandAsync</code> which expecting <code>object[] parameters</code></p>
  
  <pre><code> public async Task InsertAsync(ActionCriteria obj)
  {
      await _dbCOntext.Database.ExecuteSqlCommandAsync(obj.SpName, obj.SqlParameter) ;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public Task&lt;int&gt; ExecuteSqlCommandAsync(string sql, params object[] parameters);
  </code></pre>
  
  <p>so how will I pass sqlperameters to <code>ExecuteSqlCommandAsync</code>, so that it may execute SP with provided <strong>SqlParameters</strong> not ObjectParameters</p>