Skip to content

Adding a large number of entities to the DbContext is slow #4831

Closed
@maumar

Description

@maumar

In my scenario I'm adding about 5000 entities, each has about 2-7 entities via 1-Many relationship (there is about 18000 of those "leaf" entities). If done all at once persisting it all takes 3 min 4 sec. If done in chunks of about 500-1000 it takes 47 sec. Large portion of time is spent on adding those parent entities to the context (and I guess walking the graph and fixing up the relationships).
For my scenario however this is not necessary - I only wish to persist those entities, I generate all the keys and fixup the relationships manually via foreign keys. Perhaps we should consider a way to disable all the change tracking, for scenarios similar to this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions