/// <summary>
        /// In this demo we are running simple queries and updates and we're logging the SQL commands
        /// using tracing events.
        /// </summary>
        private static void AdvancedTracingDemo()
        {
            // disable global logging to console
            EFTracingProviderConfiguration.LogToConsole = false;

            using (var context = new ExtendedNorthwindEntities())
            {
                context.CommandExecuting += (sender, e) =>
                {
                    Console.WriteLine("Command is executing: {0}", e.ToTraceString());
                };

                context.CommandFinished += (sender, e) =>
                {
                    Console.WriteLine("Command has finished: {0}", e.ToTraceString());
                };

                var customer = context.Customers.First(c => c.CustomerID == "ALFKI");
                customer.Orders.Load();

                customer.ContactName = "Change" + Environment.TickCount;

                var newCustomer = new Customer()
                {
                    CustomerID  = "BELLA",
                    CompanyName = "Bella Vision",
                    ContactName = "Bella Bellissima",
                };

                context.AddToCustomers(newCustomer);
                context.SaveChanges();

                context.DeleteObject(newCustomer);

                context.SaveChanges();
            }

            Console.WriteLine("LOG FILE CONTENTS:");
            Console.WriteLine(File.ReadAllText("sqllogfile.txt"));
        }
        /// <summary>
        /// In this demo we are running simple queries and updates and we're logging the SQL commands
        /// using tracing events.
        /// </summary>
        private static void AdvancedTracingDemo()
        {
            // disable global logging to console
            EFTracingProviderConfiguration.LogToConsole = false;

            using (var context = new ExtendedNorthwindEntities())
            {
                context.CommandExecuting += (sender, e) =>
                    {
                        Console.WriteLine("Command is executing: {0}", e.ToTraceString());
                    };

                context.CommandFinished += (sender, e) =>
                    {
                        Console.WriteLine("Command has finished: {0}", e.ToTraceString());
                    };

                var customer = context.Customers.First(c => c.CustomerID == "ALFKI");
                customer.Orders.Load();

                customer.ContactName = "Change" + Environment.TickCount;

                var newCustomer = new Customer()
                {
                    CustomerID = "BELLA",
                    CompanyName = "Bella Vision",
                    ContactName = "Bella Bellissima",
                };

                context.AddToCustomers(newCustomer);
                context.SaveChanges();

                context.DeleteObject(newCustomer);

                context.SaveChanges();
            }

            Console.WriteLine("LOG FILE CONTENTS:");
            Console.WriteLine(File.ReadAllText("sqllogfile.txt"));
        }
        /// <summary>
        /// In this demo we are running simple queries and updates and we're logging the SQL commands
        /// to the file.
        /// </summary>
        private static void SimpleTracingDemo()
        {
            // disable global logging to console
            EFTracingProviderConfiguration.LogToConsole = false;

            using (TextWriter logFile = File.CreateText("sqllogfile.txt"))
            {
                using (var context = new ExtendedNorthwindEntities())
                {
                    context.Log = logFile;

                    // this will produce LIKE 'ALFKI%' T-SQL
                    var customer = context.Customers.Single(c => c.CustomerID.StartsWith("ALFKI"));
                    customer.Orders.Load();

                    customer.ContactName = "Change" + Environment.TickCount;

                    var newCustomer = new Customer()
                    {
                        CustomerID  = "BELLA",
                        CompanyName = "Bella Vision",
                        ContactName = "Bella Bellissima",
                    };

                    context.AddToCustomers(newCustomer);
                    context.SaveChanges();

                    context.DeleteObject(newCustomer);

                    context.SaveChanges();
                }
            }

            Console.WriteLine("LOG FILE CONTENTS:");
            Console.WriteLine(File.ReadAllText("sqllogfile.txt"));
        }
        /// <summary>
        /// In this demo we are running simple queries and updates and we're logging the SQL commands
        /// to the file.
        /// </summary>
        private static void SimpleTracingDemo()
        {
            // disable global logging to console
            EFTracingProviderConfiguration.LogToConsole = false;

            using (TextWriter logFile = File.CreateText("sqllogfile.txt"))
            {
                using (var context = new ExtendedNorthwindEntities())
                {
                    context.Log = logFile;

                    // this will produce LIKE 'ALFKI%' T-SQL
                    var customer = context.Customers.Single(c => c.CustomerID.StartsWith("ALFKI"));
                    customer.Orders.Load();

                    customer.ContactName = "Change" + Environment.TickCount;

                    var newCustomer = new Customer()
                    {
                        CustomerID = "BELLA",
                        CompanyName = "Bella Vision",
                        ContactName = "Bella Bellissima",
                    };

                    context.AddToCustomers(newCustomer);
                    context.SaveChanges();

                    context.DeleteObject(newCustomer);

                    context.SaveChanges();
                }
            }

            Console.WriteLine("LOG FILE CONTENTS:");
            Console.WriteLine(File.ReadAllText("sqllogfile.txt"));
        }