.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.

AreaWhat is generatedWhere in the project
REST APICreate, read, update and delete endpoints for each entity, under /api/<entity>Controllers/CustomerController.cs
AuthenticationRegistration and login with JWT in this example. The builder also offers OAuth2, Session, API Key, Basic Auth and OpenID Connect.Controllers/AuthController.cs
RBACRole and permission tables, and a permission check on the protected routesAuthorization/PermissionPolicyProvider.cs
MigrationsAn initial migration for the schemaMigrations/V1__initial_schema.sql, Data/SchemaMigrations.cs
Tests5 test files in the example (unit and integration)App.Tests/Controllers/CustomerControllerTests.cs
DockerfileBuilds the image and runs the app as a non-root user (uid 10001)Dockerfile
docker-composeRuns the app with a PostgreSQL database beside itdocker-compose.yml
CI pipelineA GitHub Actions workflow, when you choose it.github/workflows/ci.yml
API descriptionAn OpenAPI description of the APIProgram.cs
Health checkA health endpointProgram.cs
ConfigurationAn .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.

Folder layout, with file counts
.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 files

Real excerpts

A generated controller 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")]
The RBAC check 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();
The first migration, for Customer Migrations/V1__initial_schema.sql
CREATE 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
);
The Dockerfile Dockerfile
FROM 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 platform
A generated test App.Tests/Controllers/CustomerControllerTests.cs
public 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

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.