How to: Update Objects

Performing an update operation is an extremely simple operation. You need a reference to an existing object in the database. Once you have it, just update its properties and invoke the well-known SaveChanges method.

C#


    Customer customerToUpdate = dbContext.Customers.First();
    customerToUpdate.Fax = "[newFax]";
    dbContext.SaveChanges();

VB.NET


    Dim customerToUpdate As Customer = dbContext.Customers.First()
    customerToUpdate.Fax = "[newFax]"
    dbContext.SaveChanges()