/// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Customer CreateCustomer(global::System.Int64 id, global::System.String name)
 {
     Customer customer = new Customer();
     customer.Id = id;
     customer.Name = name;
     return customer;
 }
        static void Main(string[] args)
        {
            // =============== 构造数据 ===============
              Console.ForegroundColor = ConsoleColor.Green;

              int customerCount = 10000;

              List<Customer> customers = new List<Customer>();
              for (int i = 0; i < customerCount; i++)
              {
            Customer customer = new Customer()
            {
              Name = "Dennis Gao" + i,
              Address = "Beijing" + i,
              Phone = "18888888888" + i,
            };
            customers.Add(customer);

            Console.Write(".");
              }

              Console.WriteLine();

              try
              {
            // =============== 插入数据 ===============
            Console.WriteLine(string.Format(
              "Begin to insert {0} customers into database...",
              customerCount));

            Stopwatch watch = Stopwatch.StartNew();

            using (RetailEntities context = new RetailEntities())
            {
              context.BulkInsert(customers);
              context.SaveChanges();
            }

            watch.Stop();
            Console.WriteLine(string.Format(
              "Done, {0} customers are inserted, cost {1} milliseconds.",
              customerCount, watch.ElapsedMilliseconds));
              }
              catch (Exception ex)
              {
            Console.WriteLine(FlattenException(ex));
              }

              Console.WriteLine("=====================================");

              // =============== 查询结果 ===============
              try
              {
            using (RetailEntities context = new RetailEntities())
            {
              int countOfCustomers = context.Customers.AsQueryable().Count();
              Console.WriteLine(string.Format(
            "Now, we have {0} customers.", countOfCustomers));
            }
              }
              catch (Exception ex)
              {
            Console.WriteLine(FlattenException(ex));
              }

              Console.WriteLine("=====================================");

              // =============== 清理 ===============
              Console.WriteLine();
              Console.WriteLine("Press any key to close...");
              Console.ReadKey();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customer customer)
 {
     base.AddObject("Customers", customer);
 }