.NET (ASP.NET Core) backend generator: schema to REST API
Auxen, by Auxen Prime, generates a .NET (ASP.NET Core) (C#) backend from your database schema or a plain-English description. The output is an ordinary .NET (ASP.NET Core) project that you download and own. Build and run it with the dotnet CLI.
What you get
The table is read from a real generated project (71 files for the example schema). The last column is the file in that project.
| Area | What is generated | Where in the project |
|---|---|---|
| REST API | Create, read, update and delete endpoints for each entity, under /api/<entity> | Controllers/CustomerController.cs |
| Authentication | Registration and login with JWT in this example. The builder also offers OAuth2, Session, API Key, Basic Auth and OpenID Connect. | Controllers/AuthController.cs |
| RBAC | Role and permission tables, and a permission check on the protected routes | Authorization/PermissionPolicyProvider.cs |
| Migrations | An initial migration for the schema | Migrations/V1__initial_schema.sql, Data/SchemaMigrations.cs |
| Tests | 5 test files in the example (unit and integration) | App.Tests/Controllers/CustomerControllerTests.cs |
| Dockerfile | Builds the image and runs the app as a non-root user (uid 10001) | Dockerfile |
| docker-compose | Runs the app with a PostgreSQL database beside it | docker-compose.yml |
| CI pipeline | A GitHub Actions workflow, when you choose it | .github/workflows/ci.yml |
| API description | An OpenAPI description of the API | Program.cs |
| Health check | A health endpoint | Program.cs |
| Configuration | An .env.example listing the settings | .env.example |
The example it was generated from
Entities Customer and Invoice, with Invoice many-to-one Customer, on PostgreSQL, JWT with RBAC. Options: unit tests, integration tests, Docker, GitHub Actions pipeline and migrations. Auxen adds the authentication tables (users, roles, permissions, sessions and others) around them.
.github/workflows/ 1 file
App.Tests/ 6 files
App.Tests/Auth/ 1 file
App.Tests/Controllers/ 2 files
App.Tests/Integration/ 2 files
Authorization/ 2 files
Controllers/ 4 files
Data/ 3 files
docs/ 2 files
DTOs/ 3 files
DTOs/Auth/ 1 file
Middleware/ 2 files
Migrations/ 1 file
Models/ 13 files
Queries/ 13 files
Services/ 10 files
Validation/ 1 file
(project root) 10 filesReal excerpts
Controllers/CustomerController.cs[ApiController]
[Route("api/customer")]
[Authorize]
public class CustomerController : ControllerBase
{
private readonly ApplicationDbContext _context;
public CustomerController(ApplicationDbContext context)
{
_context = context;
}
[HttpGet]
[Authorize(Policy = "CUSTOMER_READ")]Authorization/PermissionPolicyProvider.cs{
public class PermissionPolicyProvider : IAuthorizationPolicyProvider
{
private readonly DefaultAuthorizationPolicyProvider _fallback;
public PermissionPolicyProvider(IOptions<AuthorizationOptions> options)
{
_fallback = new DefaultAuthorizationPolicyProvider(options);
}
public Task<AuthorizationPolicy> GetDefaultPolicyAsync() => _fallback.GetDefaultPolicyAsync();Migrations/V1__initial_schema.sqlCREATE TABLE IF NOT EXISTS "customer" (
customer_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_name VARCHAR(255) NOT NULL,
customer_email VARCHAR(255) UNIQUE NOT NULL,
customer_birthday DATE,
customer_active BOOLEAN NOT NULL,
customer_gender VARCHAR(255) NOT NULL,
customer_notes TEXT,
customer_created_at TIMESTAMP NOT NULL
);DockerfileFROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app/out .
# Run as the image's unprivileged "app" user, renumbered to uid and gid 10001
# (the user every generated image runs as), owning /app.
RUN groupmod --gid 10001 app && usermod --uid 10001 --gid 10001 app && chown -R app:app /app
USER 10001:10001
EXPOSE 8080
# Kestrel listens on ASPNETCORE_URLS if set, else on PORT when the platformApp.Tests/Controllers/CustomerControllerTests.cspublic class CustomerControllerTests : IDisposable
{
private static readonly JsonSerializerOptions Web = new(JsonSerializerDefaults.Web);
private readonly ApplicationDbContext _context;
private readonly Guid _userId = Guid.NewGuid();
public CustomerControllerTests()
{
var options = new DbContextOptionsBuilder<ApplicationDbContext>()
.UseInMemoryDatabase($"CustomerControllerTests-{Guid.NewGuid():N}")
.Options;
_context = new ApplicationDbContext(options);What it is built on
Read from the generated manifest: ASP.NET Core (App.csproj), Entity Framework Core (App.csproj), JWT bearer authentication (App.csproj), Swashbuckle (OpenAPI) (App.csproj), Serilog (App.csproj).
Databases
.NET (ASP.NET Core) generates for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle and Amazon Redshift. It does not generate for MongoDB.
How the generator is tested
These checks live in the Auxen repository and run against the generators themselves. They are listed here as what they do, not as a guarantee about every schema you might write.
- Generation test (npm run test:gen): generates this stack for several example schemas, then compiles the result with the dotnet CLI.
- Runtime test (npm run test:runtime): starts the generated application, connects it to a real database, registers a user, logs in, then creates and lists records over HTTP.
- Security scan: the generated project, including its Dockerfile and CI files, is scanned with Trivy for vulnerabilities, secrets and misconfiguration. The check fails on any secret, and on any high or critical finding that has a fix.
- Docker build test (npm run test:docker, run on demand): builds each stack's own Dockerfile.
Running and deploying it
Build and run it with the dotnet CLI. You download the project and deploy it wherever you run software. Auxen does not deploy the generated backend for you yet. It has a hosted sandbox where you can run the code and try its API before you download it.
Review the code before it carries real traffic, as you would any code you did not write. The terms of service say the same: generated code is provided as is, and you are responsible for reviewing, testing and securing it.
More
- Backend generator How Auxen works across all stacks.
- Schema to REST API The example schema and the generated routes.
- Pricing Free to use, with paid plans for credits and the sandbox.
- User guide Step by step, from schema to download.
- Spring Boot generator Java output.
- Kotlin Spring Boot generator Kotlin output.
- NestJS generator TypeScript output.
- FastAPI generator Python output.
- Django REST Framework generator Python output.
- Laravel generator PHP output.
- Go Gin generator Go output.
- Express.js generator TypeScript or JavaScript output.
Auxen is made by Auxen Prime Technologies Limited and lives at auxenprime.com. It is not affiliated with other companies that use the name Auxen.