using System.Linq; using Microsoft.EntityFrameworkCore; using MyProject.Data; var db = new MyDbContext(); // Instantiate a new entity var newCustomer = new Customer { Name = "John Smith", Email = "[email protected]" }; // Attach the new entity to the context db.Attach(newCustomer); // Modify the entity newCustomer.Email = "[email protected]"; // Save changes to database await db.SaveChangesAsync();In this example, a new customer entity is created and attached to the context using the Attach method. The Email property of the entity is then modified and changes are saved to the database using the SaveChangesAsync method. Package library: This code example uses the Microsoft.EntityFrameworkCore package.