© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
12 replies
Caleb Weeks

Data fetching in components?

I'm using Blazor Server.

I have set up a partial class called DataContextComponent that uses DBContextFactory to create an instance of dbContext for the lifetime of that component. I thought this would be enough to keep components isolated, but I'm finding that if there is a parent and child component that both inherit from DataContextComponent and fetch data using EF Core, I get an error saying "a second operation was started on this context instance before a previous operation completed." Am I doing something wrong?

I'd like to make reusable components that fetch their own data that I can use throughout the application. Is this an anti pattern?

Thanks for the advice!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Data-binding multiple components Blazor
C#CC# / help
3y ago
Database is not fetching data. Applied everything properly.
C#CC# / help
16mo ago
✅ EFCore fetching all data in nearly all tables after a single insert
C#CC# / help
2y ago