Blog: Persistence

First, I’ll show an example of the correct usage of an Entity Framework’s ObjectContext. At the beginning of the usage block, the ObjectContext is created; at the end it will be disposed (see using-Keyword). using (var ctx = new MyObjectContext()) { // do your stuff ctx.SaveChanges(); } Usually the code in the using block is not a whole transaction. The call of the method SaveChanges opens a new database connection, starts a new transaction, writes all changes and commits the transaction if no problems occurred. Every call of SaveChanges has its own transaction. If you want to call the SaveChanges […] Read more...