private void PopulateTodos() { using (var db = new TwoDoContext()) { var todos = db.ToDos.ToList(); ToDoListView.ItemsSource = todos; } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new TwoDoContext()) { db.Database.Migrate(); } }
private void SeedDB() { var todos = new List <ToDoItem> { new ToDoItem { Name = "Groceries", Created = DateTime.Now, Expires = DateTime.Now.AddHours(5) }, new ToDoItem { Name = "Exercise", Created = DateTime.Now, Expires = DateTime.Now.AddHours(7) } }; using (var db = new TwoDoContext()) { db.ToDos.AddRange(todos); db.SaveChanges(); } }