Start Debugging

Tag: csharp

106 posts · Page 1 of 11

How to share validation logic between server and Blazor WebAssembly
The single biggest source of validation drift in a Blazor WebAssembly + ASP.NET Core app is the urge to write the rules twice. This guide walks the only layout that scales in .NET 11: a Shared class library that owns the DTOs and their validators, consumed by both the WASM client (EditForm + DataAnnotationsValidator or Blazored.FluentValidation) and the server (minimal API endpoint filter or MVC model binding), with a tested round-trip that maps server-side ValidationProblemDetails back into the EditContext.
How to warm up EF Core's model before the first query
EF Core builds its conceptual model lazily on the first DbContext access, which is why the first query in a fresh process is several hundred milliseconds slower than every query after it. This guide covers the three real fixes in EF Core 11: a startup IHostedService that touches Model and opens a connection, dotnet ef dbcontext optimize to ship a precompiled model, and the cache-key footguns that silently rebuild the model anyway.
Next