#pragma warning restore EF1001 // Internal EF Core API usage.

        private Exception ThrowUpdateException(CosmosException exception, IUpdateEntry entry)
        {
            var documentSource = GetDocumentSource(entry.EntityType);
            var id             = documentSource.GetId(entry.SharedIdentityEntry ?? entry);

            throw exception.StatusCode switch
                  {
                      HttpStatusCode.PreconditionFailed => new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
                      HttpStatusCode.Conflict => new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
                      _ => Rethrow(exception),
                  };
        }