DbContext.SaveChangesAsync Exception Handling
问题 When scaffolding a new ApiController with asynchronous actions and Entity Framework support in Visual Studio 2013, some methods wrap DbContext.SaveChangesAsync calls in try-catch blocks. For instance, the Put method, try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return NotFound(); } throw; } From msdn.microsoft.com about DbUpdateConcurrencyException , Exception thrown by DbContext when it was expected that SaveChanges for an entity