Comments (2)
Thanks for bringing this up, @sbwalker.
Have you seen my response in #54539 (comment)? Maybe that addresses this too?
from aspnetcore.
@mkArtakMSFT I don't think it does address the issue. I am developing Static Server-Side components and when I use EF Core for data access I was running into exceptions:
"System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first."
I consulted the documentation which mentions "server-side Blazor apps":
"In server-side Blazor apps, DbContext isn't thread safe and isn't designed for concurrent use. The existing lifetimes are inappropriate for these reasons:
- Singleton shares state across all users of the app and leads to inappropriate concurrent use.
- Scoped (the default) poses a similar issue between components for the same user.
- Transient results in a new instance per request; but as components can be long-lived, this results in a longer-lived context than may be intended.
By default, consider using one context per operation. The context is designed for fast, low overhead instantiation:
using var context = new MyContext();
return await context.MyEntities.ToListAsync();"
So I modified my code to use DbContextFactory and it fully resolved my issue.
So in my experience DbContextFactory needs to be used in Static Server-Side Blazor as well as Interactive - Blazor Server scenarios.
from aspnetcore.
Related Issues (20)
- OutputCache: allow returning cached responses as fully fresh (Date: now, Age: 0) HOT 2
- Provide better developer experience when for missing dependencies HOT 1
- SDK is missing some packages for .NET Framework targets HOT 6
- DataProtectionProvider persist keys to BLOB does not use keys from BLOB HOT 17
- Microsoft.Extensions.ApiDescription.Server: Allow specifying --environment HOT 6
- Blazor Question: Order/Index of ChildComponents rendered via ChildContent/RenderFragment HOT 1
- OpenIdConnectHandler to support async state data format operations
- Don't extend the key ring cache lifetime beyond the default key lifetime HOT 1
- Make types in Microsoft.AspNetCore.DataProtection.KeyManagement.Internal internal HOT 6
- Perf improvement: multiple_queries
- Benchmark stopped running: basicminimalapipublishtrimr2rsinglefile, basicminimalapivanilla, basicminimalapivanilla
- Benchmark stopped running: basicminimalapipublishaot, basicminimalapipublishaot, todosapivanilla
- Benchmark stopped running: todosapipublishaot, todosapipublishtrimr2rsinglefile, todosapivanilla
- Benchmark stopped running: basicgrpcvanilla, basicgrpcvanilla, todosapipublishaot
- Benchmark stopped running: basicgrpcpublishaot, basicgrpcpublishaot, basicgrpcpublishtrimr2rsinglefile
- UsePathBase not working for Blazor Web App NET8 with individual accounts interactivity mode server HOT 3
- Blazor streaming rendering without JavaScript HOT 1
- SignalR tolerance for packet loss HOT 16
- Cannot create a new Blazor(Razor Component) inside a sub folder. ( this works in .NET 8) HOT 2
- Blazor DynamicComponent is reusing old instances and their states HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetcore.