public void addElement(string name, SelfReference parentSelfReference, List <SelfReference> references) { using (var context = new ModelSelfReferences()) { SelfReference reference = new SelfReference(); reference.Name = name; reference.ParentSelfReference = parentSelfReference; reference.References = references; context.SelfReferences.Add(reference); context.SaveChanges(); } }
static void TestScenariu1() { using (var db_context = new ModelSelfReferences()) { var test_reference = new SelfReference() { Name = "Test" }; db_context.SelfReferences.Add(test_reference); db_context.SaveChanges(); var get_ent = db_context.SelfReferences; foreach (var ii in get_ent) { Console.WriteLine("{0} {1} {2}", ii.Name, ii.References, ii.SelfReferenceId); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } }