title: C# Stored procedure without parameters
body: <p>I am trying to run a stored procedure without parameters using a class that inherits from dbcontext. This is my code:</p>
  
  <pre><code>MyDBContext _myDBContext = new MyDBContext();
  _myDBContext.Database.SqlQuery("MyStoredProcedure", new SqlParameter());
  </code></pre>
  
  <p>But this does not work as it is looking at the wrong overload. Even though I am using a string then params object[].</p>
  
  <p>If I have parameters in there, it works. I have done this with other stored procedured e.g.:</p>
  
  <pre><code>IEnumerable&lt;MyClass&gt; tempMyClass =
  _myDbContext.Database.SqlQuery&lt;MyClass&gt;(
      "myStoredProcedure @ID",
      new SqlParameter("@ID", 5));
  </code></pre>
  
  <p>Any idea where I am going wrong?</p>
  
  <h2>MyDBContext Definition</h2>
  
  <pre><code>class MontagueDBContext : DbContext, IUnitOfWork 
  { 
      public MontagueDBContext() : base("name=MontigueApp") 
      { 
          AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Directory.GetCurrentDirectory()); 
      } 
  
      public IDbSet&lt;Permit&gt; Permits { get; set; } 
  
      public void ChangeEntityState&lt;TEntity&gt;(TEntity item, EntityState entityState) where TEntity : class 
      { 
          this.Entry(item).State = entityState; 
      } 
  
      public EntityState GetEntityState&lt;TEntity&gt;(TEntity item) where TEntity : class 
      { 
          return this.Entry(item).State; 
      } 
  
      public new int SaveChanges() 
      { 
          return base.SaveChanges(); 
      } 
  }
  </code></pre>