Skip to content

Primitive Collection Must Implement IList #4715

Description

@chapych

Type of issue

Missing information

Description

When adding primitive collections of IEnumerable returned by LINQ without casting them to List, Array, etc., the internal method Snapshot(IEnumerable source, ValueComparer elementComparer) is invoked after the SaveChanges() call, which checks if the input parameter is an IList.

In the scenario mentioned, this method throws an exception: "The type some_type cannot be used as a primitive collection because it is not an array and does not implement 'IList'. Collections of primitive types must be arrays or ordered lists."

It may be beneficial to note this peculiarity.

Page URL

https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-8.0/whatsnew#primitive-collections

Content source URL

https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/what-is-new/ef-core-8.0/whatsnew.md

Document Version Independent Id

97203c5d-fe52-b71e-dcb3-71c9492b4e04

Article author

@ajcvickers

Activity

  1. added this to the Backlog milestone on May 1, 2024
  2. kaismic commented on Aug 2, 2024

    @kaismic

    Same issue here

  3. simonbucko commented on May 1, 2025

    @simonbucko

    Same issue here when trying to use HashSet<T> for my primitive collection

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions