//Clearing Database and resseting Primary key public void ClearDB() { using (SchoolEntities context = new SchoolEntities()) { context.ClearReads(); context.Database.ExecuteSqlCommand("use school DBCC CHECKIDENT('Readings', RESEED, 0)"); context.SaveChanges(); } //Data.Open(); //SqlCommand cmd = new SqlCommand("DBCC CHECKIDENT ('[Readings]', RESEED, 0);", Data); //SqlDataReader dr = cmd.ExecuteReader(); //Data.Close(); }