异常信息:
Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
处理方案:
public async Task DeleteAnimalInfo(string animalToken) { var dbContext = new DBContext(_configuration); var _animalInfoRepository = new EFRepository<AnimalInfo>(dbContext); var query = _animalInfoRepository .Table; query = query.Where(x => x.AnimalToken.Equals(animalToken)); if (query.Count() <= 0) { throw new Exception("does not exist in the database"); } var entity = query.FirstOrDefault(); _animalInfoRepository .Delete(query); }View Code
标签:affected,Database,actually,expected,query,operation,row From: https://www.cnblogs.com/donchen/p/16709622.html