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

The Cosmos provider ignores configured indexes #34023

Closed
ajcvickers opened this issue Jun 18, 2024 · 6 comments · Fixed by #34054
Closed

The Cosmos provider ignores configured indexes #34023

ajcvickers opened this issue Jun 18, 2024 · 6 comments · Fixed by #34054
Labels
area-cosmos breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Contributor

For example:

modelBuilder.Entity<Book>().HasIndex(e => e.ByteArray);

This will currently pass model validation, but the index is ignored. We should fail for this in model validation.

@roji
Copy link
Member

roji commented Jun 18, 2024

Or implement it ;)

@ajcvickers
Copy link
Contributor Author

Or implement it ;)

I could be wrong, but I don't think a naked .HasIndex call will ever do anything on Cosmos. You're going to need to chain something (like ForVectors) to specify how it will be used in the index specification.

@roji
Copy link
Member

roji commented Jun 19, 2024

This definitely would require more thinking... You know more than me, but it seems like it could make sense to apply a Cosmos indexing policy that includes paths only to the properties on which HasIndex() has been called, no? One big difference from relational is that in relational, there are no indexes by default, whereas in Cosmos everything seems to be indexed by default, and the policy is more of a way to do finer-grained tweaking to only index specific properties.

In any case, probably not for 9.0, so yeah, validating against HasIndex() at this point sounds like the right thing indeed...

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 21, 2024
@ajcvickers ajcvickers added this to the 9.0.0 milestone Jun 21, 2024
ajcvickers added a commit that referenced this issue Jun 21, 2024
Block unused indexes with the Cosmos provider. Fixes #34023.

Also stop adding indexes for foreign keys by convention for relational providers. Fixes #34053.
ajcvickers added a commit that referenced this issue Jul 2, 2024
Block unused indexes with the Cosmos provider. Fixes #34023.

Also stop adding indexes for foreign keys by convention for relational providers. Fixes #34053.
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview7 Jul 8, 2024
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
@roji
Copy link
Member

roji commented Sep 22, 2024

See #32517 for enabling proper support for HasIndex() on Cosmos.

@toiyabe
Copy link

toiyabe commented Dec 3, 2024

This has caused an unforeseen problem with by project. See #35264
Instead of throw an exception, how about throw a warning?

@hades200082
Copy link

Another use-case for being able to include HasIndex would be in situations/applications where you want to allow the person installing your software to choose which database provider they wish to use.

Since EF Core supports SQL and NoSQL databases now, including CosmosDB it would make sense to ensure that developers can use all of the features & functionality of EF Core in their apps without restricting it with exceptions and other errors/warnings based on the specific provider.

My end customer should be able to install my software and select SQL Server, Postgres or Cosmos and EF Core should be able to handle it (as long as I don't do any direct usage of the database/SQL myself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants