var context = new ApplicationDbContext(); var newEmployee = new Employee() { FirstName = "John", LastName = "Doe", }; context.Employees.Add(newEmployee); context.SaveChanges();
var context = new ApplicationDbContext(); var employee = context.Employees.FirstOrDefault(e => e.FirstName == "John");
var context = new ApplicationDbContext(); var employee = context.Employees.FirstOrDefault(e => e.FirstName == "John"); employee.LastName = "Smith"; context.SaveChanges();Package Library: The ApplicationDbContext class is part of the Entity Framework, which is a NuGet package library for .NET applications. Specifically, it is part of the Microsoft.EntityFrameworkCore namespace, which can be found in the Microsoft.EntityFrameworkCore package.