C# API and Blazor Implementation

Build and fix C# APIs and Blazor components with safe EF Core queries, cancellation, and focused tests.

by AgentVoltv1.0.0
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

Prompt“Build a REST API with Entity Framework Core and async patterns.”
Beforegeneric AI agent
I can help you build a solid REST API in C#. With .NET 8 and EF Core, you have a lot of good options for routing and data access. Minimal APIs are trending, but controller-based routing is still solid if you prefer that structure. You'll want to think about how you're configuring DbContext, handling async/await properly, and maybe adding some middleware for error handling. Dependency injection is pretty straightforward in modern .NET. I'd suggest setting up a test project alongside your API to keep quality high. Do you have a preference on the routing style or a specific database you're working with?
Afterwith C# API and Blazor Implementation
ASP.NET CORE MINIMAL API SCAFFOLD

1. STARTUP TEMPLATE (Program.cs):
var builder = WebApplicationBuilder.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>();
builder.Services.AddScoped<IUserService, UserService>();
var app = builder.Build();
app.MapGet("/users/{id}", GetUserById).WithName("GetUser");
app.MapPost("/users", CreateUser).WithName("CreateUser");
app.Run();

2. DBCONTEXT SETUP:
public class AppDbContext : DbContext {
  public DbSet<User> Users => Set<User>();
  protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options.UseNpgsql(connectionString);
}

3. ASYNC ENDPOINT PATTERN:
async Task<IResult> GetUserById(int id, AppDbContext db) {
  var user = await db.Users.FirstOrDefaultAsync(u => u.Id == id);
  return user != null ? Results.Ok(user) : Results.NotFound();
}

4. ERROR HANDLING MIDDLEWARE:
app.UseExceptionHandler("/error");
app.MapPost("/error", HandleError);

5. DEPENDENCY INJECTION:
builder.Services.AddScoped<IRepository<User>, UserRepository>();

TEST TEMPLATE: xUnit with Moq for repository layer.

About this skill

Your endpoint works until two requests overlap, a canceled request keeps querying the database, or a Blazor component loads everything twice. This skill builds and repairs C# applications by tracing request lifetimes, database behavior, and component state before choosing the implementation.

What it does

  • Implements minimal APIs or controllers with explicit validation, response contracts, and authorization boundaries.
  • Writes EF Core queries with bounded pagination, deterministic ordering, DTO projections, and deliberate tracking behavior.
  • Fixes async cancellation, shared DbContext access, dependency lifetime mistakes, and unobserved background work.
  • Builds Blazor components with clear state ownership, render-mode awareness, and protection against stale async results.
  • Adds focused CQRS handlers when the application benefits from them, without imposing extra architecture on small changes.
  • Produces migration plans and behavioral verification steps matched to the actual database provider and project versions.

What you get

Implementation code or a focused patch, the assumptions that affect it, and verification tied to observable behavior. Reviews identify the failing execution path and provide a concrete correction.

Best for

Developers building or maintaining C# applications on .NET 8+, especially ASP.NET Core APIs, EF Core data access, and Blazor web apps.

SKILL.md preview

SKILL.md
---
name: csharp-api-and-blazor-implementation
description: >-
  Implement and repair C# applications using ASP.NET Core, EF Core, and Blazor by tracing request lifetimes, query execution, cancellation, and component state. Use when the user says "build a minimal API", "add an EF Core endpoint", "my request keeps running after disconnect", "my Blazor component loads twice", "review this C# code", "add a CQRS handler", or "fix this DbContext concurrency error".
---

# C# API and Blazor Implementation

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →