🎓 All Courses | 📚 Blazor WASM Syllabus
Stickipedia University
📋 Study this course on TaskLoco

In a hosted Blazor WASM solution, Entity Framework Core runs on the server project — never on the WASM client. The client communicates with the server via API controllers or minimal API endpoints.

Server-Side Setup

// AppDbContext.cs
public class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options)
        : base(options) { }
    public DbSet<Product> Products => Set<Product>();
}

// Program.cs (Server)
builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(
        builder.Configuration.GetConnectionString("Default")));

Minimal API Endpoints

app.MapGet("/api/products", async (AppDbContext db) =>
    await db.Products.ToListAsync());

app.MapPost("/api/products", async (AppDbContext db, Product product) =>
{
    db.Products.Add(product);
    await db.SaveChangesAsync();
    return Results.Created($"/api/products/{product.Id}", product);
});

Shared Models

Keep model classes in the Shared project — both the Server EF Core context and the Client's HttpClient service reference the same types.


YouTube • Top 10
Blazor WASM: Integrating Entity Framework Core
Tap to Watch ›
📸
Google Images • Top 10
Blazor WASM: Integrating Entity Framework Core
Tap to View ›

Reference:

Wikipedia: Entity Framework

image for linkhttps://en.wikipedia.org/wiki/Entity_Framework

📚 Blazor WASM — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT