Skip to content

Allow keys and indexes to use properties on non-collection complex types #31246

Description

@AndriySvyryd

Split off from #13947

Depends on #31236

Related to #11336

Activity

  1. added this to the Backlog milestone on Jul 13, 2023
  2. ldeluigi commented on May 14, 2024

    @ldeluigi
  3. danilo73r commented on Jun 15, 2024

    @danilo73r
  4. hanzllcc commented on Jul 1, 2024

    @hanzllcc
  5. arm-grigoryan commented on Jul 2, 2024

    @arm-grigoryan
  6. ajcvickers commented on Jul 3, 2024

    @ajcvickers
    Contributor

    This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 9.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you.

  7. nev-21 commented on Nov 26, 2024

    @nev-21

    Hello! This feature is really important for us.

  8. sjb-sjb commented on Mar 22, 2025

    @sjb-sjb

    This would be really useful. Complex Types are needed for hiding functionality and managing the relationship of fields in the database.

    For example say I have labels in my data, and some but not all of these labels have related data. I would like to use a complex type to manage the interaction of the text label vs the referenced data. If I cannot index the text label then it is impossible to perform the required operations.

    In my particular situation I don’t need a composite key, just a key on one property within the complex type.

  9. dougwaldron commented on Apr 28, 2025

    @dougwaldron

    This has just become an issue for us, and I'm not sure how to proceed. Our database team has asked us to add some indexes in order to improve performance, and the list of indexes they've requested includes some complex type properties (as included columns).

    For example (simplified for illustration):

    CREATE INDEX requested_index_1 ON [Companies] ([OwnerId]) INCLUDE ([OwnerAddress_City])

    Since OwnerAddress is an Address value object, I have no way of adding this index in the DbContext, right? I would need something like this, which doesn't work:

    builder.Entity<Company>().HasIndex(e => new { e.OwnerId }, "requested_index_1")
        .IncludeProperties("OwnerAddress_Street");

    If the indexes are just applied on the database side, will that affect future EF Migrations? What if I skip the DbContext, but manually add these to a Migration using .CreateIndex()?

  10. AndriySvyryd commented on Apr 28, 2025

    @AndriySvyryd
    MemberAuthor

    What if I skip the DbContext, but manually add these to a Migration using .CreateIndex()?

    That would be the suggested workaround. You'll just need to remember to drop the index if one of the columns is dropped.

  11. dougwaldron commented on Apr 29, 2025

    @dougwaldron

    That would be the suggested workaround. You'll just need to remember to drop the index if one of the columns is dropped.

    That's what I'll do then. Thanks! I appreciate the quick reply.

  12. 9 remaining items

  13. added 9 commits that reference this issue on Apr 29, 2026
    55029ef
    8c4181d
    8b88d60
    f5883b8
    5f9e7d1
    e719275
    3b6ecb2
    d13942f
    9d7d45e
  14. added a commit that references this issue on May 19, 2026
    01907fd
  15. added a commit that references this issue on May 19, 2026
    d6aee5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions