Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos: Provider does not support any Microsoft.Azure.Cosmos.Client version after 3.0.0.1 #16504

Closed
rennr opened this issue Jul 8, 2019 · 1 comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@rennr
Copy link

rennr commented Jul 8, 2019

Both preview 6 and preview 5 of the Azure Cosmos DB provider do not support any Microsoft.Azure.Cosmos.Client version after 3.0.0.1-preview. I assume earlier previews have the same problem, but I did not test them.

For example, calls to the context's Database.EnsureCreated() or SaveChanges() fail with the following message:

System.TypeLoadException: 'Could not load type 'Microsoft.Azure.Cosmos.CosmosDatabaseResponse' from assembly 'Microsoft.Azure.Cosmos.Client, Version=3.0.0.19, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.'

Here is the stack trace from a call to SaveChanges():

   at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.CreateItemOnceAsync(DbContext _, ValueTuple`2 parameters, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.CreateItemOnce(DbContext context, ValueTuple`2 parameters)
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func`3 operation, Func`3 verifySucceeded, TState state)
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.CreateItem(String containerId, JToken document)
   at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosDatabaseWrapper.Save(IUpdateEntry entry)
   at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosDatabaseWrapper.SaveChanges(IList`1 entries)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()
   at [REDACTED]
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

The error message changes based on the version of the Microsoft.Azure.Cosmos library you have installed. If you install version 3.0.0.1-preview (November 30, 2018) of the library, the calls succeed and work as intended.

The dependencies of Microsoft.EntityFrameworkCore.Cosmos show Microsoft.Azure.Cosmos >= 3.0.0.1-preview. This should probably be "=" not ">=" if lack of support for the new versions of the 3.0 Cosmos client is intentional.

Steps to reproduce

Install the latest (or any version after 3.0.0.1) Microsoft.Azure.Cosmos from NuGet. Install Microsoft.EntityFrameworkCore.Cosmos preview 5 or 6.

Try to create a model object and add it to the database. Upon calling SaveChanges() on the context, the exception indicated above will be thrown.

Further technical details

EF Core version: 3.0.0-preview5.19227.1
Database Provider: Microsoft.EntityFrameworkCore.Cosmos
Operating system: Windows 10
IDE: Visual Studio 2019 Preview 3

@ajcvickers
Copy link
Member

@rennr This is because EF Core 3.0 is a preview and the Cosmos API is also in preview, and so as a point-in-time thing these two particular versions of the previews do not work together. For now, you'll need to use the same version that EF builds against. This should not be a problem when both are out of preview.

@ajcvickers ajcvickers added the closed-no-further-action The issue is closed and no further action is planned. label Jul 8, 2019
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

2 participants