diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index c809fa93b6f..e2d1c235866 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -8,7 +8,7 @@ updates:
- dependency-name: Castle.Core
- dependency-name: Humanizer.Core
- dependency-name: IdentityServer4.EntityFramework
- - dependency-name: Azure.Cosmos
+ - dependency-name: Microsoft.Azure.Cosmos
- dependency-name: Microsoft.CSharp
- dependency-name: Microsoft.Data.SqlClient
- dependency-name: Microsoft.DotNet.PlatformAbstractions
diff --git a/src/EFCore.Cosmos/EFCore.Cosmos.csproj b/src/EFCore.Cosmos/EFCore.Cosmos.csproj
index 7c65b686b16..904951dda78 100644
--- a/src/EFCore.Cosmos/EFCore.Cosmos.csproj
+++ b/src/EFCore.Cosmos/EFCore.Cosmos.csproj
@@ -21,7 +21,7 @@
-
+
diff --git a/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs
index f7f015d84a5..dc9e8f08d73 100644
--- a/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs
+++ b/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs
@@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
diff --git a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs
index e1f69174a94..c8c42564b38 100644
--- a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs
+++ b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs
@@ -4,8 +4,8 @@
using System;
using System.ComponentModel;
using System.Net;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
index 9f388f8782d..3309d3bc01a 100644
--- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
+++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs
@@ -6,8 +6,8 @@
using System.Globalization;
using System.Net;
using System.Text;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs
index 375e3b07b81..d597da75d6b 100644
--- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs
+++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs
@@ -3,7 +3,7 @@
using System;
using System.Net;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs b/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs
index ff1b1ad4a06..df14c951248 100644
--- a/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs
+++ b/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs
@@ -3,7 +3,7 @@
using System;
using System.Net;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
index 198768949a1..c59d65b6749 100644
--- a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
@@ -11,9 +11,8 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Azure;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Diagnostics.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
@@ -141,7 +140,7 @@ public virtual async Task CreateDatabaseIfNotExistsOnceAsync(
var response = await Client.CreateDatabaseIfNotExistsAsync(_databaseId, cancellationToken: cancellationToken)
.ConfigureAwait(false);
- return response.GetRawResponse().Status == (int)HttpStatusCode.Created;
+ return response.StatusCode == HttpStatusCode.Created;
}
///
@@ -188,13 +187,13 @@ public virtual async Task DeleteDatabaseOnceAsync(
{
using var response = await Client.GetDatabase(_databaseId).DeleteStreamAsync(cancellationToken: cancellationToken)
.ConfigureAwait(false);
- if (response.Status == (int)HttpStatusCode.NotFound)
+ if (response.StatusCode == HttpStatusCode.NotFound)
{
return false;
}
- EnsureSuccessStatusCode(response);
- return response.Status == (int)HttpStatusCode.NoContent;
+ response.EnsureSuccessStatusCode();
+ return response.StatusCode == HttpStatusCode.NoContent;
}
///
@@ -239,13 +238,13 @@ private async Task CreateContainerIfNotExistsOnceAsync(
},
cancellationToken: cancellationToken)
.ConfigureAwait(false);
- if (response.Status == (int)HttpStatusCode.Conflict)
+ if (response.StatusCode == HttpStatusCode.Conflict)
{
return false;
}
- EnsureSuccessStatusCode(response);
- return response.Status == (int)HttpStatusCode.Created;
+ response.EnsureSuccessStatusCode();
+ return response.StatusCode == HttpStatusCode.Created;
}
///
@@ -300,7 +299,7 @@ private async Task CreateItemOnceAsync(
.ConfigureAwait(false);
ProcessResponse(response, entry);
- return response.Status == (int)HttpStatusCode.Created;
+ return response.StatusCode == HttpStatusCode.Created;
}
///
@@ -363,7 +362,7 @@ private async Task ReplaceItemOnceAsync(
.ConfigureAwait(false);
ProcessResponse(response, entry);
- return response.Status == (int)HttpStatusCode.OK;
+ return response.StatusCode == HttpStatusCode.OK;
}
///
@@ -425,7 +424,7 @@ public virtual async Task DeleteItemOnceAsync(
.ConfigureAwait(false);
ProcessResponse(response, entry);
- return response.Status == (int)HttpStatusCode.NoContent;
+ return response.StatusCode == HttpStatusCode.NoContent;
}
private static ItemRequestOptions CreateItemRequestOptions(IUpdateEntry entry)
@@ -443,7 +442,7 @@ private static ItemRequestOptions CreateItemRequestOptions(IUpdateEntry entry)
etag = converter.ConvertToProvider(etag);
}
- return new ItemRequestOptions { IfMatch = new ETag((string)etag) };
+ return new ItemRequestOptions { IfMatchEtag = (string)etag };
}
private static PartitionKey CreatePartitionKey(IUpdateEntry entry)
@@ -465,21 +464,21 @@ private static PartitionKey CreatePartitionKey(IUpdateEntry entry)
return partitionKey == null ? PartitionKey.None : new PartitionKey((string)partitionKey);
}
- private static void ProcessResponse(Response response, IUpdateEntry entry)
+ private static void ProcessResponse(ResponseMessage response, IUpdateEntry entry)
{
- EnsureSuccessStatusCode(response);
+ response.EnsureSuccessStatusCode();
var etagProperty = entry.EntityType.GetETagProperty();
if (etagProperty != null && entry.EntityState != EntityState.Deleted)
{
- entry.SetStoreGeneratedValue(etagProperty, response.Headers.ETag?.ToString());
+ entry.SetStoreGeneratedValue(etagProperty, response.Headers.ETag);
}
var jObjectProperty = entry.EntityType.FindProperty(StoreKeyConvention.JObjectPropertyName);
if (jObjectProperty != null
&& jObjectProperty.ValueGenerated == ValueGenerated.OnAddOrUpdate
- && response.ContentStream != null)
+ && response.Content != null)
{
- using var responseStream = response.ContentStream;
+ using var responseStream = response.Content;
using var reader = new StreamReader(responseStream);
using var jsonReader = new JsonTextReader(reader);
@@ -561,11 +560,11 @@ internal virtual async Task ExecuteReadItemAsync(
return JObjectFromReadItemResponseMessage(responseMessage);
}
- private static JObject JObjectFromReadItemResponseMessage(Response response)
+ private static JObject JObjectFromReadItemResponseMessage(ResponseMessage responseMessage)
{
- EnsureSuccessStatusCode(response);
+ responseMessage.EnsureSuccessStatusCode();
- var responseStream = response.ContentStream;
+ var responseStream = responseMessage.Content;
var reader = new StreamReader(responseStream);
var jsonReader = new JsonTextReader(reader);
@@ -574,7 +573,7 @@ private static JObject JObjectFromReadItemResponseMessage(Response response)
return new JObject(new JProperty("c", jObject));
}
- private IAsyncEnumerable CreateQuery(
+ private FeedIterator CreateQuery(
string containerId,
string partitionKey,
CosmosSqlQuery query)
@@ -597,7 +596,7 @@ private IAsyncEnumerable CreateQuery(
return container.GetItemQueryStreamIterator(queryDefinition, requestOptions: queryRequestOptions);
}
- private async Task CreateSingleItemQuery(
+ private async Task CreateSingleItemQuery(
string containerId,
string partitionKey,
string resourceId,
@@ -647,19 +646,9 @@ private static bool TryReadJObject(JsonTextReader jsonReader, out JObject jObjec
return true;
}
}
-
return false;
}
- private static void EnsureSuccessStatusCode(Response response)
- {
- var httpStatusCode = response.Status;
- if (httpStatusCode < 200 || httpStatusCode > 299)
- {
- throw new HttpException(response);
- }
- }
-
private sealed class DocumentEnumerable : IEnumerable
{
private readonly CosmosClientWrapper _cosmosClient;
@@ -692,12 +681,12 @@ private sealed class Enumerator : IEnumerator
private readonly string _partitionKey;
private readonly CosmosSqlQuery _cosmosSqlQuery;
- private Response _response;
+ private ResponseMessage _responseMessage;
private Stream _responseStream;
private StreamReader _reader;
private JsonTextReader _jsonReader;
- private IAsyncEnumerator _query;
+ private FeedIterator _query;
public Enumerator(DocumentEnumerable documentEnumerable)
{
@@ -717,18 +706,18 @@ public bool MoveNext()
{
if (_jsonReader == null)
{
- _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery).GetAsyncEnumerator();
+ _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery);
- if (!_query.MoveNextAsync().AsTask().GetAwaiter().GetResult())
+ if (!_query.HasMoreResults)
{
Current = default;
return false;
}
- _response = _query.Current;
- EnsureSuccessStatusCode(_response);
+ _responseMessage = _query.ReadNextAsync().GetAwaiter().GetResult();
+ _responseMessage.EnsureSuccessStatusCode();
- _responseStream = _response.ContentStream;
+ _responseStream = _responseMessage.Content;
_reader = new StreamReader(_responseStream);
_jsonReader = CreateJsonReader(_reader);
}
@@ -758,8 +747,8 @@ public void Dispose()
{
ResetRead();
- _response?.Dispose();
- _response = null;
+ _responseMessage?.Dispose();
+ _responseMessage = null;
}
public void Reset()
@@ -797,12 +786,12 @@ private sealed class AsyncEnumerator : IAsyncEnumerator
private readonly CosmosSqlQuery _cosmosSqlQuery;
private readonly CancellationToken _cancellationToken;
- private Response _response;
+ private ResponseMessage _responseMessage;
private Stream _responseStream;
private StreamReader _reader;
private JsonTextReader _jsonReader;
- private IAsyncEnumerator _query;
+ private FeedIterator _query;
public JObject Current { get; private set; }
@@ -822,19 +811,18 @@ public async ValueTask MoveNextAsync()
if (_jsonReader == null)
{
- _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery)
- .GetAsyncEnumerator(_cancellationToken);
+ _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery);
- if (!await _query.MoveNextAsync().ConfigureAwait(false))
+ if (!_query.HasMoreResults)
{
Current = default;
return false;
}
- _response = _query.Current;
- EnsureSuccessStatusCode(_response);
+ _responseMessage = await _query.ReadNextAsync(_cancellationToken).ConfigureAwait(false);
+ _responseMessage.EnsureSuccessStatusCode();
- _responseStream = _response.ContentStream;
+ _responseStream = _responseMessage.Content;
_reader = new StreamReader(_responseStream);
_jsonReader = CreateJsonReader(_reader);
}
@@ -864,8 +852,8 @@ public async ValueTask DisposeAsync()
{
await ResetReadAsync().ConfigureAwait(false);
- await _response.DisposeAsyncIfAvailable().ConfigureAwait(false);
- _response = null;
+ await _responseMessage.DisposeAsyncIfAvailable().ConfigureAwait(false);
+ _responseMessage = null;
}
}
}
diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs
index 1f47920376e..b484ea75163 100644
--- a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs
@@ -7,8 +7,8 @@
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
@@ -37,7 +37,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
/// The implementation does not need to be thread-safe.
///
///
- public class CosmosDatabaseWrapper : Database
+ public class CosmosDatabaseWrapper : EntityFrameworkCore.Storage.Database
{
private readonly Dictionary _documentCollections
= new Dictionary();
@@ -113,13 +113,9 @@ public override int SaveChanges(IList entries)
rowsAffected++;
}
}
- catch (CosmosException cosmosException)
+ catch (CosmosException ex)
{
- throw ThrowUpdateException(cosmosException, entry);
- }
- catch (HttpException httpException)
- {
- throw ThrowUpdateException(httpException, entry);
+ throw ThrowUpdateException(ex, entry);
}
}
@@ -181,13 +177,9 @@ public override async Task SaveChangesAsync(
rowsAffected++;
}
}
- catch (CosmosException cosmosException)
- {
- throw ThrowUpdateException(cosmosException, entry);
- }
- catch (HttpException httpException)
+ catch (CosmosException ex)
{
- throw ThrowUpdateException(httpException, entry);
+ throw ThrowUpdateException(ex, entry);
}
}
@@ -361,7 +353,7 @@ public virtual DocumentSource GetDocumentSource([NotNull] IEntityType entityType
}
#pragma warning disable EF1001 // Internal EF Core API usage.
- // #16707
+ // Issue #16707
private IUpdateEntry GetRootDocument(InternalEntityEntry entry)
{
var stateManager = entry.StateManager;
@@ -392,26 +384,12 @@ private Exception ThrowUpdateException(CosmosException exception, IUpdateEntry e
{
var documentSource = GetDocumentSource(entry.EntityType);
var id = documentSource.GetId(entry.SharedIdentityEntry ?? entry);
- throw exception.Status switch
- {
- (int)HttpStatusCode.PreconditionFailed =>
- new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
- (int)HttpStatusCode.Conflict =>
- new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
- _ => Rethrow(exception),
- };
- }
-
- private Exception ThrowUpdateException(HttpException exception, IUpdateEntry entry)
- {
- var documentSource = GetDocumentSource(entry.EntityType);
- var id = documentSource.GetId(entry.SharedIdentityEntry ?? entry);
- throw exception.Response.Status switch
+ throw exception.StatusCode switch
{
- (int)HttpStatusCode.PreconditionFailed =>
- new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
- (int)HttpStatusCode.Conflict =>
- new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
+ HttpStatusCode.PreconditionFailed =>
+ new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
+ HttpStatusCode.Conflict =>
+ new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }),
_ => Rethrow(exception),
};
}
diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs
index c8d19ca68d4..452072f447e 100644
--- a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs
@@ -5,8 +5,8 @@
using System.Globalization;
using System.Linq;
using System.Net;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Storage;
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
@@ -101,24 +101,24 @@ protected override bool ShouldRetryOn(Exception exception)
{
if (exception is CosmosException cosmosException)
{
- return IsTransient(cosmosException.Status);
+ return IsTransient(cosmosException.StatusCode);
}
if (exception is HttpException httpException)
{
- return IsTransient(httpException.Response.Status);
+ return IsTransient(httpException.Response.StatusCode);
}
if (exception is WebException webException)
{
- return IsTransient((int)((HttpWebResponse)webException.Response).StatusCode);
+ return IsTransient(((HttpWebResponse)webException.Response).StatusCode);
}
return false;
- static bool IsTransient(int status)
- => status == (int)HttpStatusCode.ServiceUnavailable
- || status == (int)HttpStatusCode.TooManyRequests;
+ static bool IsTransient(HttpStatusCode statusCode)
+ => statusCode == HttpStatusCode.ServiceUnavailable
+ || statusCode == HttpStatusCode.TooManyRequests;
}
///
@@ -133,24 +133,14 @@ static bool IsTransient(int status)
return baseDelay == null
? null
: CallOnWrappedException(lastException, GetDelayFromException)
- ?? baseDelay;
+ ?? baseDelay;
}
private static TimeSpan? GetDelayFromException(Exception exception)
{
if (exception is CosmosException cosmosException)
{
- if (cosmosException.TryGetHeader("x-ms-retry-after-ms", out var delayString)
- && TryParseMsRetryAfter(delayString, out var delay))
- {
- return delay;
- }
-
- if (cosmosException.TryGetHeader("Retry-After", out delayString)
- && TryParseRetryAfter(delayString, out delay))
- {
- return delay;
- }
+ return cosmosException.RetryAfter;
}
if (exception is HttpException httpException)
@@ -186,7 +176,6 @@ static bool IsTransient(int status)
}
return null;
-
static bool TryParseMsRetryAfter(string delayString, out TimeSpan delay)
{
delay = default;
diff --git a/src/EFCore.Cosmos/Storage/Internal/HttpException.cs b/src/EFCore.Cosmos/Storage/Internal/HttpException.cs
index 282b8f6ccf0..fad9cf7a856 100644
--- a/src/EFCore.Cosmos/Storage/Internal/HttpException.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/HttpException.cs
@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Azure;
+using System.Net.Http;
using JetBrains.Annotations;
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
@@ -21,7 +21,7 @@ public class HttpException : Exception
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public HttpException([NotNull] Response response)
+ public HttpException([NotNull] HttpResponseMessage response)
: base(response.ReasonPhrase)
{
// An error occurred while sending the request.
@@ -34,6 +34,6 @@ public HttpException([NotNull] Response response)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual Response Response { get; }
+ public virtual HttpResponseMessage Response { get; }
}
}
diff --git a/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs b/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs
index 582ee0cfa33..becf243bda4 100644
--- a/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs
@@ -3,7 +3,7 @@
using System.IO;
using System.Text;
-using Azure.Cosmos.Serialization;
+using Microsoft.Azure.Cosmos;
using Newtonsoft.Json;
namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal
diff --git a/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs
index 800d4fd0a18..00a33e26fe4 100644
--- a/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs
@@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using Azure.Cosmos;
using JetBrains.Annotations;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
diff --git a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs
index 534062d69cb..91b65a9e005 100644
--- a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs
@@ -3,7 +3,7 @@
using System;
using System.Threading.Tasks;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
diff --git a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
index df2b11cfb40..2bbd914a745 100644
--- a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs
@@ -4,8 +4,8 @@
using System;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
-using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.TestUtilities;
@@ -1211,8 +1211,8 @@ public async Task Add_update_delete_query_throws_if_no_container()
context.Add(customer);
Assert.StartsWith(
- @"Message: {""Errors"":[""Resource Not Found",
- (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
+ "Response status code does not indicate success: NotFound (404); Substatus: 0",
+ (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
}
using (var context = new CustomerContext(options))
@@ -1220,8 +1220,8 @@ public async Task Add_update_delete_query_throws_if_no_container()
context.Add(customer).State = EntityState.Modified;
Assert.StartsWith(
- @"Message: {""Errors"":[""Resource Not Found",
- (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
+ "Response status code does not indicate success: NotFound (404); Substatus: 0",
+ (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
}
using (var context = new CustomerContext(options))
@@ -1229,15 +1229,15 @@ public async Task Add_update_delete_query_throws_if_no_container()
context.Add(customer).State = EntityState.Deleted;
Assert.StartsWith(
- @"Message: {""Errors"":[""Resource Not Found",
- (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
+ "Response status code does not indicate success: NotFound (404); Substatus: 0",
+ (await Assert.ThrowsAsync(() => context.SaveChangesAsync())).Message);
}
using (var context = new CustomerContext(options))
{
Assert.StartsWith(
- @"Message: {""Errors"":[""Resource Not Found",
- (await Assert.ThrowsAsync(() => context.Set().SingleAsync())).Message);
+ "Response status code does not indicate success: NotFound (404); Substatus: 0",
+ (await Assert.ThrowsAsync(() => context.Set().SingleAsync())).Message);
}
}
diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs
index 909c3db8a5c..66104927428 100644
--- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs
+++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
-using Azure.Cosmos;
+using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -172,24 +172,30 @@ public override async Task CleanAsync(DbContext context)
var cosmosClient = context.Database.GetCosmosClient();
var database = cosmosClient.GetDatabase(Name);
var containerIterator = database.GetContainerQueryIterator();
- await foreach (var containerProperties in containerIterator)
+ while (containerIterator.HasMoreResults)
{
- var container = database.GetContainer(containerProperties.Id);
- var partitionKey = containerProperties.PartitionKeyPath[1..];
- var itemIterator = container.GetItemQueryIterator(
- new QueryDefinition("SELECT * FROM c"));
-
- var items = new List<(string Id, string PartitionKey)>();
- await foreach (var item in itemIterator)
+ foreach (var containerProperties in await containerIterator.ReadNextAsync())
{
- items.Add((item["id"].ToString(), item[partitionKey]?.ToString()));
- }
+ var container = database.GetContainer(containerProperties.Id);
+ var partitionKey = containerProperties.PartitionKeyPath[1..];
+ var itemIterator = container.GetItemQueryIterator(
+ new QueryDefinition("SELECT * FROM c"));
- foreach (var item in items)
- {
- await container.DeleteItemAsync