efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Indexes are created by default for foreign keys in non-relational databases

Open ajcvickers opened this issue 1 year ago • 6 comments

The convention is debatable even on a relational database, where the use of FKs in joins make this often a useful index to have. Doing it speculatively for non-relational databases seems a step too far.

They are ignored by the Cosmos and in-memory provider, so this should not be breaking.

ajcvickers avatar Jun 21 '24 12:06 ajcvickers

This seems like quite a breaking change if I understand correctly (I always appreciated that theses indexes were created)

ErikEJ avatar Jun 21 '24 12:06 ErikEJ

I always appreciated that theses indexes were created

Can you explain more? Neither the Cosmos nor the in-memory provider used the indexes in any way.

ajcvickers avatar Jun 21 '24 12:06 ajcvickers

So I probably misunderstood - this only affects non-relational providers, you will still create indexes for relational providers?

ErikEJ avatar Jun 21 '24 12:06 ErikEJ

Yep.

ajcvickers avatar Jun 21 '24 12:06 ajcvickers

I am just looking at this comment in the PR: "Also stop adding indexes for foreign keys by convention for relational providers." - I think that is what confused / worried me...

ErikEJ avatar Jun 21 '24 12:06 ErikEJ

Typo in the PR!

ajcvickers avatar Jun 21 '24 12:06 ajcvickers

Design decision: only remove the convention for Cosmos.

ajcvickers avatar Jul 02 '24 11:07 ajcvickers