Q:

Renumbering the remaining records after deleting one of them

I have a database in SQL server using Entity Framework ASP.NET MVC. I have a column named "S No." representing serial numbers. Now when I delete a record from database, obviously the "S No." skips that records serial number. I want to re number the "S No." column using my controller. Is there any algorithm so that i can easily renumber them again?
Here is the code of AddFeature() method where i am numbering the "S No." column.
  public ActionResult AddFeature(Models.SoftwareFeatureList s)
    {
        ViewBag.Username = uname;
        ViewBag.UserType = utype;
        try
        {
            c = new DatabaseZTBLEntities();
            s.FormId = formid;
            int identity = c.SoftwareFeatureLists.Where(u=>u.FormId.Equals(formid)).Count() +1;
            s.S_No_ = identity;
            c.SoftwareFeatureLists.Add(s);

            c.SaveChanges();
        }
        catch(Exception e)
        {
            ViewBag.Error = e.Message;
            return View("error");
        }
        finally
        {
            c.Database.Connection.Close();
        }
        return Redirect("FeaturesListPage");
    }

A:

Two solutions:

Do not keep S_no as a column in database, but generate its value on the fly when returning the records on Read operation.
If you still want to keep S_no in the database, you need to update your database directly (using triggers) whenever any delete happens.
row_number() over(partition by formId order by formId)

