public DatabaseInitializer() { using (var context = new GameModelContainer()) { if (!context.Database.Exists()) { context.Database.Create(); GenerateDefaultPlayer(context); GenerateGamesFromResource(); GenerateGameParamsFromResources(); GenerateGameResultsFromResources(); context.GameParams.AddRange(_gameParams); context.GameResults1.AddRange(_gameResults); context.Games.AddRange(_games); context.SaveChanges(); } context.Database.Initialize(false); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { if (player.Name.Length > 0 && player.Surname.Length > 0) { using (var context = new GameModelContainer()) { context.Players.Add(new Player() { Name = player.Name, Surname = player.Surname, Age = player.Age }); context.SaveChanges(); } _lPlayerAdded.Visibility = Visibility.Visible; } }