private void Window_Loaded(object sender, RoutedEventArgs e) { var options = new DbContextOptionsBuilder <LernsiegContext>() .UseSqlServer("server=(LocalDB)\\mssqllocaldb;attachdbfilename=C:\\Users\\mosha\\Documents\\Schule\\5.Klasse\\POS\\Lernsieg\\Lernsieg.mdf;database=Lernsieg;integrated security=True") .Options; var db = new LernsiegContext(options); try { int nrSchools = db.Schools.Count(); //School school = db.Schools.Where(x => x.Id == 401046).FirstOrDefault(); //txt.Content = $"name: {school.Name}"; DataContext = new LernsiegViewModel().Init(db); } catch (Exception exc) { Console.WriteLine($"Error message: {exc}"); Title = exc.Message; } }
public LernsiegService(LernsiegContext db) { this.db = db; }