public void SaveNewContactToRepository()
        {
            // arrange

            // note connection string is in app.config
            Contact con = new Contact();
            ContactsDb db = new ContactsDb();
            con.fname = "Adam";
            con.lname = "VandenElzen";
            con.phone = "867-5309";
            db.Contacts.AddObject(con);

            // act
            db.SaveChanges();

            // Assert -- see if the record retreived from the database matches the one i just added
            Contact savedContact = (from d in db.Contacts where d.id == con.id select d).Single();

            Assert.AreEqual(savedContact.fname, con.fname);
            Assert.AreEqual(savedContact.lname, con.lname);
            Assert.AreEqual(savedContact.phone, con.phone);

            // cleanup
            db.Contacts.DeleteObject(con);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == string.Empty ||
                TextBox2.Text == string.Empty ||
                TextBox3.Text == string.Empty)
            {
                Label1.Text = "Please enter proper details first";
                return;
            }

            Contact con = new Contact();
            con.fname = TextBox1.Text;
            con.lname = TextBox2.Text;
            con.phone = TextBox3.Text;

            ContactsDb db = new ContactsDb();
            db.Contacts.AddObject(con);
            if (db.SaveChanges() == 1)
            {
                Label1.Text = "Contact added Successfully";
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContacts(Contact contact)
 {
     base.AddObject("Contacts", contact);
 }
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static Contact CreateContact(global::System.Int32 id)
 {
     Contact contact = new Contact();
     contact.id = id;
     return contact;
 }