private void ResetDatabase()
        {
            using (TestEFDeployEntities db = new TestEFDeployEntities(connstr))
            {
                db.Database.ExecuteSqlCommand("truncate table TestTable");
                db.SaveChanges();

                TestTable tt1 = new TestTable();
                tt1.DataValue = "this is record 1";
                db.TestTables.Add(tt1);
                db.SaveChanges();

                TestTable tt2 = new TestTable();
                tt2.DataValue = "this is record 2";
                db.TestTables.Add(tt2);
                db.SaveChanges();

                TestTable tt3 = new TestTable();
                tt3.DataValue = "this is record 3";
                db.TestTables.Add(tt3);
                db.SaveChanges();

                LoadListbox();
                lbIDs.SelectedIndex = 0;
            }
        }
        private void LoadListbox()
        {
            // load up the pkid listbox
            lbIDs.Items.Clear();
            using (TestEFDeployEntities ctx = new TestEFDeployEntities(this.connstr))
            {
                var mypkids = (from rows in ctx.TestTables
                               select rows).ToList();

                foreach (var row in mypkids)
                {
                    lbIDs.Items.Add(row.pkid.ToString());
                }
            }
        }
        private void lbIDs_SelectedIndexChanged(object sender, EventArgs e)
        {
            int param = GetSelectedPKID();

            // update data textbox with change in selected pkid
            using (TestEFDeployEntities ctx = new TestEFDeployEntities(this.connstr))
            {
                var mypkids = (from rows in ctx.TestTables
                               where rows.pkid == param
                               select rows).ToList();

                if (mypkids != null && mypkids.Count > 0)
                {
                    txtData.Text = mypkids[0].DataValue;
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            // save changes to the data field to the currently selected pkid record
            int param = GetSelectedPKID();

            if (param > 0)
            {
                using (TestEFDeployEntities ctx = new TestEFDeployEntities(this.connstr))
                {
                    TestTable savethis = (from rows in ctx.TestTables
                                          where rows.pkid == param
                                          select rows).FirstOrDefault();

                    savethis.DataValue = txtData.Text;

                    ctx.SaveChanges();
                }
            }
        }
        private void btnNew_Click(object sender, EventArgs e)
        {
            //create new testtable object
            //save it, letting the identity 1, 1 get set
            //reload listbox, go to appropriate index
            //focus one data textbox

            int       myid  = 0;
            TestTable newtt = new TestTable();

            //create the new record, get the pkid
            using (TestEFDeployEntities db = new TestEFDeployEntities(connstr))
            {
                db.TestTables.Add(newtt);
                db.SaveChanges();

                myid = newtt.pkid;
            }

            //reload the listbox
            LoadListbox();
        }