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

EnsureCreated fails with CosmosDB if Scale not set #26885

Open
SamueleFurnari opened this issue Dec 3, 2021 · 4 comments
Open

EnsureCreated fails with CosmosDB if Scale not set #26885

SamueleFurnari opened this issue Dec 3, 2021 · 4 comments

Comments

@SamueleFurnari
Copy link

If you want to use the EnsureCreated with a CosmosDB provider, the request fails with a generic 400 - BadRequest if the Cosmos instance does not have Scale setted.

To reproduce this, try to create a CosmosDB Database with Provision throughput unselected and in your code (for example in the Configure method of Startup class, try to execute the code:

dbContext.Database.EnsureCreated();

If you create the database with the Provision throughput selected and configured, the ensure works as expected.

EF Core version:
Database provider: Microsoft.EntityFrameworkCore.Cosmos v.5.0.10 and 5.0.12
Target framework: .NET 5.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.11.7

@ajcvickers
Copy link
Contributor

/cc @AndriySvyryd

@AndriySvyryd
Copy link
Member

We might be able to throw a better exception message.

@SamueleFurnari In 6.0 we added methods on EntityTypeBuilder to configure the provisioned throughput on the associated container: HasManualThroughput and HasAutoscaleThroughput

@SamueleFurnari
Copy link
Author

@AndriySvyryd thank you. Currently I'm using the v.5.0.10.0 that if I understand well, does not have a way to manage the autoscale throughput.

If I want to maintains the actual EF version, the only way to be sure that EnsureCreated works, is to be sure that the database has the throughput set. Is this correct?

Thank you!

@AndriySvyryd
Copy link
Member

@SamueleFurnari Yes or let EF create the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants