c# - How can i reconnect an entity dataset inside using statement when a SQLException occurs? -
    the situation have long running method looping through thousands of rows , doing processing , updates.  loop nested inside using statement.   the problem when came work in morning see connection failed @ 8pm sqlexception , lost 12 hours of processing time.  how can reconnect , continue processing loop programatically?   my idea this:   using (var _data = new my.ef.myentities()) {     (int = 1; < 17348; i++)     {         try         {           //do lots of stuff         }         catch (sqlexception ex)         {             writelogfile("error @ id" + i.tostring(), ex);             i--;             if (_data.database.connection.state != system.data.connectionstate.open)             {                 _data.  // what?  nothing looks useful here reconnect             }         }      } }   this dev code, not production or user environment.  i'm doing seeding database 10'000's of records , linked records idea load testing, i'm not programming possibilitie...