title: Entity Frameworks ExecuteSqlCommand Null parameter giving error
body: <p>I am using Entity Framework 5. When I call a stored procedure where the parameter is null, I get </p>
  
  <blockquote>
    <p>"stored proc" expects parameter x which was not supplied.  </p>
  </blockquote>
  
  <p>I need to be able to use <code>ExecuteSqlCommand</code> even if its parameters are null:</p>
  
  <pre><code> Sub SaveMANUALPosting(ByVal ExpiryDate AS DateTime)
  
      db.Database.ExecuteSqlCommand("exec spLC_STAGEPostingLCAmendment @argExpiryDate", 
       New SqlParameter("argExpiryDate", If((IsNothing(ExpiryDate)), DBNull.Value, ExpiryDate)))
  
   end Sub
  </code></pre>
  
  <p>The above code does not work of course, but illustrates what I am trying to do. How can I pass a <code>DbNull</code> value if the incoming parameter is null?</p>