managing-blazor-server-data-access

Configure IDbContextFactory and state management for Blazor Server applications.

19|2|Updated May 13, 2026
One-click install
npx skills add https://github.com/microsoft/upgrade-agent-plugins --skill managing-blazor-server-data-access
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: managing-blazor-server-data-access
Source: https://github.com/microsoft/upgrade-agent-plugins/tree/main/plugins/upgrade-agent/extenders/upgrade-dotnet/upgrade/skills/lazy/web/webforms/managing-blazor-server-data-access
Command: npx skills add https://github.com/microsoft/upgrade-agent-plugins --skill managing-blazor-server-data-access

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires EntityFrameworkCore, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill manages data access and state in Blazor Server applications, solving common issues such as session management, DbContext threading errors, and cart state loss.

Core Features & Use Cases

  • Data Access Configuration: Configure IDbContextFactory for long-lived circuits, alternatives to Session/ViewState/Application state, and migration of DataSource to service injection.
  • Session Management: Addresses issues like Session NULL in WebSocket circuits and DbContext threading/concurrent operation errors.
  • Use Case: Use this Skill to handle data access in Blazor Server, configure state management, and resolve data access failures.

Quick Start

Run the command: configure-data-access BlazorServerApp -c Web.config

Frequently Asked Questions about managing-blazor-server-data-access

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I resolve DbContext threading and concurrent operation errors in Blazor Server?

To resolve Blazor Server DbContext threading errors, configure an IDbContextFactory to manage DbContext lifetimes. This prevents concurrent operation exceptions caused by long-lived WebSocket circuits sharing a single scoped DbContext instance.

Why does Session state return NULL in my Blazor Server WebSocket circuit?

Session state returns NULL in Blazor Server WebSocket circuits because standard HTTP Session is disconnected during long-lived SignalR connections. This skill replaces Session state with alternative state management solutions suited for long-lived circuits.

How do I configure Entity Framework Core data access for long-lived Blazor Server circuits?

Configure EF Core data access for long-lived Blazor Server circuits by injecting an IDbContextFactory instead of a scoped DbContext. Run the command 'configure-data-access BlazorServerApp -c Web.config' to apply the required service configurations.

What is the best way to prevent shopping cart state loss in Blazor Server?

The best way to prevent cart state loss in Blazor Server is migrating from traditional Session or ViewState to robust state management alternatives designed for long-lived circuits. This skill configures dependency injection to maintain cart persistence reliably.

Do I need to migrate DataSource configurations to service injection for Blazor Server data access?

Yes, you need to migrate DataSource configurations to service injection for Blazor Server data access. This migration replaces obsolete Web.config data source patterns with modern dependency injection and IDbContextFactory configurations.