Getting Started

Quickstart

[object Object]

Prerequisites

  • .NET SDK 8.0 or newer on the PATH
  • Reachable SQL Server instance with the stored procedures

1) Install the CLI

dotnet tool install --global xtraq

2) Initialize the project

xtraq init --connection "Server=.;Database=AppDb;Trusted_Connection=True;"
  • .xtraqconfig holds tracked defaults (namespace, output, schema allow-list).
  • .env keeps the connection string and stays out of git.

3) Snapshot / Generate

xtraq

The default command runs snapshot + build and writes artefacts to Xtraq/.

4) Wire into ASP.NET Core

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddXtraqDbContext(options =>
{
    options.ConnectionString = builder.Configuration.GetConnectionString("DefaultConnection")
        ?? throw new InvalidOperationException("Missing connection string.");
});

var app = builder.Build();

app.MapPost("/orders", async (
    OrderCreateInput input,
    IXtraqDbContext db,
    CancellationToken ct) =>
{
    var result = await db.ConfigureProcedure(input)
        .ExecuteAsync(ctx => ctx.OrderCreateAsync, ct);

    return Results.Ok(result);
});

app.Run();
  • AddXtraqDbContext registers the generated helpers.
  • SessionSettings applies recommended SQL Server SET flags after opening each connection (quoted identifiers, ANSI NULLS/PADDING/WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, NOCOUNT ON, NUMERIC_ROUNDABORT OFF). Override with options.SessionSettings.Clear().With... if you need a different mix.
  • ConfigureProcedure keeps the handler lean and allows policies/transactions later.

5) Run and test

dotnet run
curl -X POST https://localhost:5001/orders \
  -H "Content-Type: application/json" \
  -d '{ "OrderNumber": "A-100", "Amount": 42 }'

Want more detail?