This is a sample code for the presentation "Minimal APIs in ASP.NET Core".
To learn what is new in ASP.NET Core Minimal APIs, you can check What's new in .NET world? GitHub repository, sections for .NET 7 and .NET 8.
- November 2022, Advanced Technology Days, Zagreb
- September 2022, Road to Init, Banja Luka
- September 2022, KulenDayz, Osijek
- May 2023, Thrive, Lipica
- August 2023, .NET Day, Zürich
- October 2023, Network, Neum
There are three sample projects in a solution and one test project.
- MvcSample demonstrates a regular MVC application using controllers
- MinimalSample is the same application but written with new ASP.NET Minimal APIs
- MinimalSample.Refactored is the same sample, but refactored to feature folder organization using Carter
The test project is demonstrating how to write integration tests that target Minimal APIs
The projects are created using .NET 6 (only the MvcSample project) and .NET 8. You need to have .NET 8 SDK installed locally.
Before running the samples, you need to make sure that the SQLite database are created and pre-seeded with the data. To ensure that, run the following commands:
dotnet tool restore
dotnet ef database update --project .\src\MinimalApis.MvcSample\MinimalApis.MvcSample.csproj
dotnet ef database update --project .\src\MinimalApis.MinimalSample\MinimalApis.MinimalSample.csproj
dotnet ef database update --project .\src\MinimalApis.MinimalSample.Refactored\MinimalApis.MinimalSample.Refactored.csproj
You can run each sample one by one and check the Swagger UI for a list of available endpoints. Each sample uses a different port and a database, so they can all be run at the same time.
dotnet run --project .\src\MinimalApis.MvcSample\MinimalApis.MvcSample.csproj
dotnet run --project .\src\MinimalApis.MinimalSample\MinimalApis.MinimalSample.csproj --launch-profile https
dotnet run --project .\src\MinimalApis.MinimalSample.Refactored\MinimalApis.MinimalSample.Refactored.csproj --launch-profile https
Accessing the Swagger UI:
Run the following from the root of the repository:
dotnet test .\tests\MinimalApis.MinimalSample.Tests\MinimalApis.MinimalSample.Tests.csproj
See LICENSE file.