我正在将代码迁移到DotNet Core。我需要解决对OptimisticConcurrencyException
的引用。我需要加载哪个NuGet包?
我正在将代码迁移到DotNet Core。我需要解决对OptimisticConcurrencyException
的引用。我需要加载哪个NuGet包?
DbUpdateConcurrencyException
。SaveChanges
过程中捕获 DbUpdateConcurrencyException
。DbUpdateConcurrencyException.Entries
为受影响的实体准备新的更改集。OptimisticConcurrencyException
在 System.Data.Entity.Core
命名空间中,它是 EntityFramework
(EF6)库的一部分。
EF Core是实体框架库的完全重写,因此很可能OptimisticConcurrencyException
从未进入EF Core。
还有this thread建议在EF6中捕获DbUpdateConcurrencyException
。还指出,在EF6中的两个异常只会增加混乱。因此,EF Core团队可能决定只实现其中一个。
如果仍然有疑问,请在EF Core github存储库中创建问题。他们乐于回答问题,并且这可能对具有相同问题的其他用户也有所帮助。 :)
catch (Exception e) when (e is OptimisticConcurrencyException || e is DbUpdateConcurrencyException)
。 - Bob.at.Indigo.Health
OptimisticConcurrencyException
和DbUpdateConcurrencyException
,请在我的问题答案中告诉我。 (如果有一些合理官方的文档说'OptimisticConcurrencyException'在.NET Core中已经不存在,那就更好了。) - Bob.at.Indigo.Health