title: SQL Server Output Parameter showing null value in EF C#
body: <p>I have a below stored procedure with output parameter.</p>
  
  <pre><code>ALTER proc [dbo].[CRS_GetNewMessageCount]
  @CaseId int,
  @Type varchar(50),
  @Location varchar(50),
  @Count int out
  as
  
  begin
  if @location='admin'
      begin
      if @type='consumer'
      select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsConsumerType=1 and fdIsReadatAdmin=0)
      else
      select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsMemberType=1 and fdIsReadatAdmin=0)
      end
  else
  begin
      if @type='consumer'
      select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsConsumerType=1 and fdIsReadatFront=0)
  else
  select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsMemberType=1 and fdIsReadatFront=0)
  END
  SELECT @Count
  END
  </code></pre>
  
  <p>It is perfect working at SQL server see below output  :</p>
  
  <p><img src="https://i.stack.imgur.com/CMWq9.jpg"></p>
  
  <p>I am calling this <code>stored procedure</code> through <code>Entity Framework</code> :</p>
  
  <pre><code>using (DbContext db = new DbContext())
              {
                  try
                  {
                      var NewMessage = new ObjectParameter("Count", typeof(int));
                      int returnValue = 0;
                      db.CRS_GetNewMessageCount(CaseId, type, location, NewMessage);
                      int.TryParse(NewMessage.Value.ToString(), out returnValue);
                      return returnValue;
                  }
                  catch { return 0; }
              }
  </code></pre>
  
  <p>It gives <code>null</code> value in output parameter. </p>
  
  <p>Please help.</p>