title: Last Inserted Auto Increment Id using ASP.NET MVC & Entity Framework
body: <p>Here I'm going to get last inserted auto-increment <code>ID</code> for the <code>Newstbl</code>. But here in the normal scenario we can take it as order by DESCENDING ORDER &amp; get the first record.</p>
  
  <p>But here I use ASP.NET MVC &amp; Entity Framework, I'm stuck there. <code>NewsId</code> is the auto-increment Id</p>
  
  <p>My code:</p>
  
  <pre><code>public int GetLastInsertedId()
  {
          return (from x in context.Newstbl
                  orderby x.NewsId 'DESC' 
                  select x)
  }
  </code></pre>