Thursday, January 15, 2015

Entity Framework: CRUD

Unit of Work

DbContext is used to create a Unit of Work. DbContext keeps track of changes in the unit of work and performs the DB updates transactionally.

using (var ctx = new DbContext())
{
   // Unit of Work
   // EF can track changes via proxies (proxy knows when object changed).
   // Proxy auto gen by EF that looks data object.
   // Used to track changes on a field by field basis
   // .SaveChanges() checks changes and executes appropriate SQL against the DB

}