public MainViewModel() { if (IsInDesignMode) { // Code runs in Blend --> create design time data. } else { db = new WidgetDataContext(); Refresh(); } }
private static void SetupDb() { WidgetDataContext db = new WidgetDataContext(); if (!db.DatabaseExists()) { db.CreateDatabase(); #region Set Initial Database Version var updater = db.CreateDatabaseSchemaUpdater(); updater.DatabaseSchemaVersion = 1; updater.Execute(); #endregion Set Initial Database Version } #region DatabaseSchemaUpdater //else //{ // var updater = db.CreateDatabaseSchemaUpdater(); // if (updater.DatabaseSchemaVersion < 2) // { // // make some updates // // // updater.AddTable<Log>(); // updater.AddColumn<Widget>("CreationDate"); // updater.DatabaseSchemaVersion = 2; // updater.Execute(); // foreach (var item in db.Widgets) // { // item.CreationDate = DateTime.Now; // } // db.SubmitChanges(); // } //} #endregion DatabaseSchemaUpdater }