namespace consoleapplication3
{< br> class Program
{< br> static void main (string [] ARGs)
{< br> model1container M = new model1container ();
Student s = new student ();
S. name = "James";
M. student set. addobject (s); // Add operation
M. savechanges (); // added running
console. writeline ("added successfully");
var slist = from Stu in M. student set select Stu; // query operation
foreach (student SL in slist)
{< br> console. writeline ("output Student name:");
console. writeline (SL. name);
}
console. writeline ("update operation");
Student SC = new student ();
SC. id = 2;
SC. name = "slightly changed";
M. student set. attach (SC); // This sentence is very important to write the object to be updated to the object set
M. objectstatemanager. changeobjectstate (SC, system. data. entitystate. modified); // update the object
M. savechanges (); // run the update operation.
console. writeline ("delete operation");
Student SD = new student ();
SD. id = 3;
M. student set. attach (SD);
M. objectstatemanager. changeobjectstate (SD, system. data. entitystate. deleted); // delete operation
M. savechanges ();
}< BR >}