Пример #1
0
        static void Main(string[] args)
        {
            //EntityFrameworkProfiler.Initialize();

            //have to do this b4 profiler, since profiler doesn't like create / delete database
            Database.SetInitializer(new OrtmanFamilyInitializer());

            PrintDads();

            Console.WriteLine("========= after initialization ===========");
            var context = new FamilyMembers();

            //since i know i've only just created 1 dad, i just hardcode the ID
            var chris = context.Dads.First(x => x.FirstName == "Chris");

            var clara = new Kid()
            {
                Name = "Clara", Birthday = DateTime.Parse("1/21/2009")
            };

            chris.Kids.Add(clara);

            context.SaveChanges();

            PrintDads();



            Console.WriteLine("All Done");
            Console.ReadLine();
        }
Пример #2
0
        private static void PrintDads()
        {
            Console.WriteLine("======Dads======");
            var family = new FamilyMembers();

            foreach (var c in family.Dads.Include(x => x.Kids))
            {
                Console.WriteLine(c.ToString());
            }
        }