Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

ASP.NET Core docs
ASP.NET Core
Getting Started with ASP.NET CoreProject Structure and ConfigurationCore ConceptsData, Validation and AuthenticationTestingDeployment
Discussions

ASP.NET Core guide · 4/6

Data, Validation and Authentication

Each HTTP request is handled independently, so durable state lives in a database or another external store. This chapter uses Entity Framework Core (EF Core) for data access, then covers input validation and the basics of authentication.

Add EF Core

EF Core is Microsoft's object-relational mapper. Add a database provider and the design-time package, then install the dotnet-ef tool:

dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet tool install --global dotnet-ef

Other providers include Microsoft.EntityFrameworkCore.SqlServer and Npgsql.EntityFrameworkCore.PostgreSQL.

DbContext and entities

// Data/TodoDb.cs
using Microsoft.EntityFrameworkCore;

public class Todo
{
    public int Id { get; set; }
    public required string Title { get; set; }
    public bool IsDone { get; set; }
}

public class TodoDb(DbContextOptions<TodoDb> options) : DbContext(options)
{
    public DbSet<Todo> Todos => Set<Todo>();
}

Register the context in Program.cs. AddDbContext uses the scoped lifetime, so each request gets its own instance:

builder.Services.AddDbContext<TodoDb>(options =>
    options.UseSqlite(builder.Configuration.GetConnectionString("Default")));

Migrations

Migrations turn model changes into versioned schema changes:

dotnet ef migrations add InitialCreate   # generates Migrations/*.cs
dotnet ef database update                # applies pending migrations
dotnet ef migrations script --idempotent -o migrate.sql

Review the generated migrations and commit them. In production, apply a SQL script or a migration bundle (dotnet ef migrations bundle) as a deployment step rather than migrating automatically at startup.

CRUD endpoints

var todos = app.MapGroup("/todos");

todos.MapGet("/", async (TodoDb db) =>
    await db.Todos.AsNoTracking().ToListAsync());

todos.MapGet("/{id:int}", async (int id, TodoDb db) =>
    await db.Todos.FindAsync(id) is { } todo ? Results.Ok(todo) : Results.NotFound());

todos.MapPost("/", async (Todo todo, TodoDb db) =>
{
    db.Todos.Add(todo);
    await db.SaveChangesAsync();
    return Results.Created($"/todos/{todo.Id}", todo);
});

todos.MapDelete("/{id:int}", async (int id, TodoDb db) =>
    await db.Todos.Where(t => t.Id == id).ExecuteDeleteAsync() == 1
        ? Results.NoContent()
        : Results.NotFound());

Use the async APIs so request threads are not blocked on I/O, and AsNoTracking() for read-only queries. Binding entities straight from the request is fine for a demo; real apps usually accept separate request types (DTOs) so clients cannot set fields such as Id.

Validation

With controllers marked [ApiController], data annotation attributes on the request type are checked automatically, and invalid input gets a 400 response with a ValidationProblemDetails body. Recent versions of ASP.NET Core bring the same behavior to minimal APIs with builder.Services.AddValidation().

using System.ComponentModel.DataAnnotations;

public class CreateTodo
{
    [Required, StringLength(200)]
    public string Title { get; set; } = "";

    public bool IsDone { get; set; }
}

For complex rules, many teams use the FluentValidation library, or return TypedResults.ValidationProblem(errors) from their own checks.

Authentication basics

Authentication establishes who the caller is; authorization decides what they may do. APIs commonly use JWT bearer tokens:

dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
dotnet user-jwts create    # issues a development token and configures the app
using System.Security.Claims;

builder.Services.AddAuthentication().AddJwtBearer();
builder.Services.AddAuthorization();

var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/me", (ClaimsPrincipal user) => user.Identity?.Name)
   .RequireAuthorization();

AddJwtBearer() reads its settings from the Authentication:Schemes:Bearer configuration section, which dotnet user-jwts fills in for Development. Controllers use [Authorize] and [AllowAnonymous]. Apps with server-rendered pages typically use cookie authentication and ASP.NET Core Identity for sign-in and password hashing, or delegate sign-in to an OpenID Connect provider.

Summary

  • EF Core maps classes to tables; register a scoped DbContext with AddDbContext.
  • Manage the schema with dotnet ef migrations add and apply migrations as a deployment step.
  • Data annotations validate input automatically in [ApiController] controllers and, with AddValidation(), in minimal APIs.
  • Add an authentication scheme, call UseAuthentication and UseAuthorization, and protect endpoints with RequireAuthorization or [Authorize].
Questions about this chapter?
Previous chapterCore ConceptsNext chapterTesting

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.