简体   繁体   English

什么NuGet包包含DotNet Core的OptimisticConcurrencyException?

[英]What NuGet package contains OptimisticConcurrencyException for DotNet Core?

I'm migrating code to DotNet Core. 我正在将代码迁移到DotNet Core。 I need to resolve a reference to OptimisticConcurrencyException . 我需要解析对OptimisticConcurrencyException的引用。 What NuGet package do I need to load? 我需要加载什么NuGet包?

If you're migrating to EF Core, the closest you can get is DbUpdateConcurrencyException . 如果您要迁移到EF Core,则最接近的是DbUpdateConcurrencyException

The general approach to handle a concurrency conflicts is: 处理并发冲突的一般方法是:

  1. Catch DbUpdateConcurrencyException during SaveChanges . SaveChanges期间捕获DbUpdateConcurrencyException
  2. Use DbUpdateConcurrencyException.Entries to prepare a new set of changes for the affected entities. 使用DbUpdateConcurrencyException.Entries为受影响的实体准备一组新更改。
  3. Refresh the original values of the concurrency token to reflect the current values in the database. 刷新并发令牌的原始值以反映数据库中的当前值。
  4. Retry the process until no conflicts occur. 重试该过程,直到不发生冲突。

source: https://docs.microsoft.com/en-us/ef/core/saving/concurrency 来源: https//docs.microsoft.com/en-us/ef/core/saving/concurrency

EDIT: 编辑:

OptimisticConcurrencyException is in the System.Data.Entity.Core namespace which is part of the EntityFramework (EF6) library. OptimisticConcurrencyException位于System.Data.Entity.Core命名空间中,该命名空间是EntityFramework (EF6)库的一部分。

EF Core is a complete rewrite of the entity framework library so it's highly likely that OptimisticConcurrencyException never went in EF Core. EF Core是对实体框架库的完全重写,因此很有可能OptimisticConcurrencyException永远不会进入EF Core。

There was also this thread that suggested to just catch DbUpdateConcurrencyException in EF6. 还有这个线程建议在DbUpdateConcurrencyException中捕获DbUpdateConcurrencyException And it was also pointed out that the two exceptions in EF6 just adds confusion. 并且还指出EF6中的两个例外只会增加混乱。 So maybe the EF Core team decided to just implement one over the other. 所以也许E​​F核心团队决定只实施一个。

If still in doubt, create an issue in the EF Core github repo. 如果仍有疑问,请在EF Core github repo中创建一个问题。 They're receptive of answering the issues and it might help other users too with the same problem. 他们接受回答问题,也可能帮助其他用户解决同样的问题。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 像nuget那样的dotnet核心软件包 - nustache like nuget package for dotnet core 是什么原因导致.net核心nuget包中出现不匹配,该包包含需要字典的抽象类 - What causes a mismatch in a .net core nuget package that contains an abstract class requiring a dictionary Linux 上的 Nuget 和 dotnet - 使用/打包提供的包 - Nuget & dotnet on linux - using/package a provided package Dotnet 还原为 NuGet package 提供 301 错误 - Dotnet restore gives 301 error for a NuGet package 如何解决dotnet核心中的nuget依赖地狱? - How to solve nuget dependency hell in dotnet core? Dotnet 包包括 nuget 包到 output nuget ZEFE90A8E604A7C840E8ZD03A - Dotnet Pack include nuget packages into output nuget package 有没有人有使用 NuGet 的 DocumentFormat.OpenXML.DotNet.Core 包构建控制台应用程序 (C#) 的经验? - Does anyone have experience building a Console App (C#) using the package DocumentFormat.OpenXML.DotNet.Core from NuGet? 哪个 nuget 包包含方法 GetSheetService()? - Which nuget package contains the method GetSheetService()? 是否有包含 Dapper.Net SqlBuilder 的 nuget 包? - Is there a nuget package that contains Dapper.Net SqlBuilder? 如何找到包含程序集的nuget包? - How to find the nuget package that contains an assembly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM