public void Update(StudentMore item, int key)
 {
     try
     {
         var obj = sms.StudentsMore.Where(p => p.StudentId == key).FirstOrDefault();
         if (obj.StudentId == null)
         {
             item.StudentId = key;
             Create(item);
         }
         obj.Address     = item.Address;
         obj.PhoneNumber = item.PhoneNumber;
         obj.School      = item.School;
         sms.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
 public StudentMore Create(StudentMore item)
 {
     try
     {
         sms.StudentsMore.Add(item);
         sms.SaveChanges();
         return(item);
     }
     catch (SqlException e)
     {
         if (e.Number == 2601)
         {
             throw new PrimaryKeyDuplicateException("student already registed");
         }
         throw;
     }
     catch (Exception)
     {
         throw;
     }
 }