Skip to content

System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. #307

@cwbrandsdal

Description

@cwbrandsdal

I get the error message "System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext" sometimes when I have a blazor server page that uses sub components that have different IRepository injected into them. And they all have code that gets data from the db on OnInitializedAsync.

I guess I'm using repositories all wrong. How can I make this safe? When I use the DBContext directly it all works fine. How can I work around this?

So sorry if this is a completely wrong place for this post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions