Ejemplo n.º 1
0
        public void DoClean(Action <DbContext> action)
        {
            var connString = LocalDbFactory.Instance.CreateConnectionStringBuilder();

            connString.InitialCatalog = "ContosoUniversity";
            var dbContext = new SchoolContext(connString.ToString());

            try
            {
                dbContext.BeginTransaction();
                action(dbContext);
                dbContext.CloseTransaction();
            }
            catch (Exception e)
            {
                dbContext.CloseTransaction(e);
                throw;
            }
        }