Reputation: 51
My teacher told today that Minimal API allow start with minimal code and evolve the application with time in a way you end having a Controller folder and automatic routing as an traditional ASP.NET Coree MVC app/API.
I loved the idea of fast starting development with a simple file mapping all routes in so simple way but would like a way to convert it to a full routing when it becomes cluttered or when development becomes more serious or client/teacher ask for it without coding everything from scratch again.
Initially I just want a simple way to have Postgres Migrations, my connection string in appsettings.json
, Swagger, JWT+SocialLogin and would be great have my models on a separate project too.
I was searching about and just found a Microsoft article, but nothing about turning routing in the traditional way.
It pops-up here too: Controllers and Endpoints in Net 6 Minimal API
Upvotes: 5
Views: 8116
Reputation: 9993
Hi , When you use Minimal Api in .Net 6 , There is no builder.Services.AddControllers()
and
app.MapControllers()
in Program,cs
.
But , If you want to evolve an ASP.NET Core Minimal APIs to a full controller model , You need to add builder.Services.AddControllers()
and
app.MapControllers()
in Program.cs
by yourself
Attention: there is some Differences between minimal APIs
and APIs with controllers
, you can read this document to learn more details
Upvotes: 8