protected void Page_Load(object sender, EventArgs e)
 {
     if (dbInitialized == false)
     {
         using (TravelBookingEntities context = new TravelBookingEntities())
         {
             context.CreateDatabase();
             context.SeedData();
         }
         dbInitialized = true;
     }
 }
Exemple #2
0
        public TravelBookingForm()
        {
            InitializeComponent();

            // create new context, do not dispose

            context = new TravelBookingEntities();

            // initialize the database using extension methods

            context.CreateDatabase();

            // make sure you add code to the SeedData() method to add the data to the db

            context.SeedData();

            this.Load                  += (s, e) => TravelBookingForm_Load();
            buttonFilter.Click         += ButtonFilter_Click;
            buttonUpdateDatabase.Click += ButtonUpdateDatabase_Click;
        }