The ASP.NET application
To get started, create a new ASP.NET project using the ASP.NET Core Web API template. Put the files wherever is convenient for you and choose the latest version of .NET (this book was written with .NET 8).
The basic structure of our application will be as follows:
- Controllers with endpoints
- Services
- Repositories
We’ll review endpoints and all the rest of this as we go.
Program.cs
You won’t have to edit Program.cs
for this application but it is worth a few minutes of your time to review it:
using Cars.Data; using Cars.Data.Interfaces; using Cars.Data.Repositories; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); // Load DB configuration and register the connection factory for ...