Getting Started
Getting Started
Install SqlOS and run the Todo sample in five minutes.
DbContext can useYou'll learn how to install SqlOS, wire a minimal host, run the Todo sample, and pick the next doc for your use case.
Add SqlOS to your ASP.NET app.
Implement the SqlOS interfaces and call AddSqlOS during host setup.
Call MapSqlOS(), start the app, and open the admin dashboard.
dotnet add package SqlOSA complete minimal Program.cs for an owned web app with hosted auth:
using Microsoft.EntityFrameworkCore;
using SqlOS.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.AddSqlOS<AppDbContext>(options =>
{
options.AuthServer.Issuer = "https://localhost:5001/sqlos/auth";
options.AuthServer.PublicOrigin = "https://localhost:5001";
options.AuthServer.SeedOwnedWebApp(
"web",
"My Application",
"https://localhost:5001/auth/callback");
});
var app = builder.Build();
app.MapSqlOS();
app.Run();Your context implements the SqlOS interfaces. This sample includes both auth and FGA:
public sealed class AppDbContext : DbContext,
ISqlOSAuthServerDbContext,
ISqlOSFgaDbContext
{
public DbSet<Project> Projects => Set<Project>();
public IQueryable<SqlOSFgaAccessibleResource> IsResourceAccessible(
string subjectId,
string permissionKey)
=> FromExpression(() =>
IsResourceAccessible(subjectId, permissionKey));
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.UseSqlOS(GetType());
}
}appsettings.json needs a SQL Server connection string and optional dashboard password:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=SqlOSApp;Trusted_Connection=True;TrustServerCertificate=True"
},
"SqlOS": {
"Dashboard": {
"AuthMode": "Password",
"Password": "change-me-in-production"
}
}
}var app = builder.Build();
app.MapSqlOS();This gives you:
| Path | What it does |
|---|---|
/sqlos | Admin dashboard |
/sqlos/auth/* | OAuth 2.0 endpoints, hosted AuthPage, Email OTP, invitations |
/sqlos/admin/auth | Auth management UI |
/sqlos/admin/fga | FGA management UI |
Register your frontend as an OAuth client so users can sign in immediately:
builder.AddSqlOS<AppDbContext>(options =>
{
options.AuthServer.SeedOwnedWebApp(
"my-app",
"My Application",
"http://localhost:3000/auth/callback");
});/sqlos/admin/auth/ (or /sqlos for the main dashboard).appsettings.json when AuthMode is Password.
Fastest path — hosted auth, simple FGA, and client onboarding:
dotnet run --project examples/SqlOS.Todo.AppHost/SqlOS.Todo.AppHost.csprojThe AppHost starts SQL Server and the Todo API. Open the URL shown in the console, then /sqlos/admin/auth/.
The Todo sample covers:
SqlOS runs its own SQL scripts on host startup. Your EF migrations do not own those tables.
If you migrate before the app has started SqlOS once, call SqlOSBootstrapper.InitializeAsync() first. The example API shows that pattern when your tables reference SqlOS.
Branded login, dashboard, and OAuth flows out of the box.
Build your own UI on the same OAuth and session APIs.
Model resources, grants, and EF Core query filters.
Endpoint and method reference when you need a specific contract.