title: how to call Stored Proc in EF core and Asp.net core?
body: <p>I have a basic stored proc SearchMovies </p>
  
  <p><code>alter PROCEDURE SearchMovies<br>
      @CategoryIds     varchar(50) = null
  AS  ...</code></p>
  
  <p>I make some calls from data layer:</p>
  
  <pre><code>    var categoryIds = new SqlParameter("CategoryIds", "6");
  
       var aaa = entities.FromSql("EXECUTE dbo.SearchMovies @CategoryIds", categoryIds ); =&gt; empty values
  
       var bbb= entities.FromSql("EXECUTE dbo.SearchMovies @CategoryIds={0}", categoryIds ); =&gt; error: Must declare the scalar variable "@p0".
  
       var ccc= entities.FromSql("EXECUTE dbo.SearchMovies @CategoryIds={0}", "6");  =&gt; works
  </code></pre>
  
  <p>so how come the first 2 calls not working, I followed <a href="https://docs.microsoft.com/en-us/ef/core/querying/raw-sql" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/querying/raw-sql</a></p>
  
  <p>Thanks all.</p>
  
  <p>UPDATED:</p>
  
  <p>looks like I messed up things.</p>
  
  <pre><code> var categoryIds = new SqlParameter("@CategoryIds", "6");
  entities.FromSql("EXECUTE dbo.SearchMovies @CategoryIds", categoryIds )
  </code></pre>
  
  <p>works fine.  </p>
  
  <p>Thanks all for help.</p>