FastSharp is a lightweight library for building APIs in C# and ASP.NET Core (Minimal APIs). Full CRUDs and custom endpoints, organized by domain modules, in a single line of code.
In ASP.NET Core Minimal APIs, even a simple CRUD for one entity means writing the same boilerplate over and over. FastSharp eliminates that:
// This single line generates 6 REST endpoints backed by EF Core
AddCRUD<Product, int>("products");No controllers. No repetition. Just modules organized by domain.
dotnet add package FastSharp.Modules
dotnet add package FastSharp.Models
FastSharp.Modulesis the core.FastSharp.Modelscontains only the model interfaces — add it to projects that don't need the full core.
The minimum setup requires 4 files. This example uses an in-memory database so you can run it immediately.
1. Install the dependencies
dotnet add package FastSharp.Modules
dotnet add package FastSharp.Models
dotnet add package Microsoft.EntityFrameworkCore.InMemory2. Your model
// Models/Product.cs
using FastSharp.Models;
public class Product : IModel<int>
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
}3. Your DbContext
// Data/AppDbContext.cs
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
public DbSet<Product> Products => Set<Product>();
}4. Your module
// Modules/Products/ProductsModule.cs
using FastSharp.Modules;
public class ProductsModule : Module<AppDbContext>
{
public ProductsModule()
{
ConfigureModule("api/", module => module.WithTags("Products"));
AddCRUD<Product, int>("products");
}
}5. Program.cs
using FastSharp.Modules;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(opt =>
opt.UseInMemoryDatabase("fastsharp-demo"));
builder.Services.AddFastSharpEndpoints();
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapFastSharpEndpoints();
app.MapOpenApi();
app.Run();Run the project and open /openapi/v1.json — you'll see all 6 endpoints ready to use.
| Method | Route | Description |
|---|---|---|
GET |
/api/products/paged |
Paginated list |
GET |
/api/products |
Full list |
GET |
/api/products/{id} |
Get by ID |
POST |
/api/products |
Create |
PUT |
/api/products/{id} |
Update |
DELETE |
/api/products/{id} |
Delete |
Disable specific endpoints
AddCRUD<Product, int>("products", crud =>
{
crud.DisableEndpoint(GenericEndpoint.GetList);
});Use DTOs
AddCRUD<Product, int>("products", crud =>
{
crud.Update<ProductDto>();
// Or apply DTOs to all endpoints:
// crud.ConfigureAll<ProductDto>();
});Add metadata for OpenAPI
AddCRUD<Product, int>("products", crud =>
{
crud.Get(endpoint =>
endpoint.WithDescription("Get a product by its unique identifier"));
});Add custom endpoints to the same module
public ProductsModule()
{
ConfigureModule("api/", module => module.WithTags("Products"));
AddCRUD<Product, int>("products");
// Custom endpoints inherit the module's group configuration
Include<CheckProductStock>();
}public class CheckProductStock : IEndpoint
{
public void Map(RouteGroupBuilder app)
{
app.MapGet("/{id}/stock", async ([FromRoute] int id) =>
{
return Results.Ok($"Checking stock for product {id}");
})
.WithTags("prueba");
}
}FastSharp is built on Modular Slices — group your logic by domain, not by technical layers.
YourProject/
└── Modules/
├── Products/
│ ├── ProductsModule.cs
│ ├── CheckProductStock.cs
│ └── ProductDto.cs
└── Orders/
├── OrdersModule.cs
└── OrderDto.cs
Each module is a self-contained unit: its routes, its DTOs, its custom endpoints. FastSharp auto-discovers all modules in your assembly — no manual registration needed.
- .NET 10 or higher
- Entity Framework Core
- A registered
DbContextin the dependency container - Models implementing
IModel<TId> - Modules inheriting from
Module<TDbContext>
MIT