How to Setup a Minimal API in .NET 7

preview_player
Показать описание
In this tutorial we'll take a look at how to configure a minimal api in .NET 7. We'll also take a look at the Minimal API filters, added into .NET 7 and how to properly set them up.

👍If you enjoyed this tutorial, please like this video consider subscribing for more content like this!

😮 By the end of this tutorial, you will be able to:
- Setup a Minimal API in .NET 7
- Create Minimal API CRUD endpoints
- Install and configure FluentValidation
- Understand API Filters and how they work
- Configure Minimal API filters for an enterprise level application

🖊 Useful Notes:
Versions used in the recording of this tutorial:
- .NET SDK: 7.0.100-preview.4.22252.9
- .NET Runtime 7.0.0-preview.4.22229.4
- Visual Studio 2022 17.3.0 Preview 1.1
To generate the migration using EF Core Tools, use the following command in your Package Manager Console in Visual Studio:
👉 Add-Migration InitialCreate -c MarketMgrDbContext -o DataAccess/Migrations
To update the database with a generated migration:
👉 Update-Database InitialCreate

📦 Dependencies:
👉 FluentValidation.AspNetCore --version 11.0.2
👉 Microsoft.EntityFrameworkCore.SqlServer --version 7.0.0-preview.4.22229.2
👉 Microsoft.EntityFrameworkCore.Tools –version 7.0.0-preview.4.22229.2

0:00 - Intro
00:30 - Setup a New Minimal Web API
01:30 - Setup and Configure SQL Server Database
04:22 – Create and Apply SQL Server Migrations
05:29 – Create Minimal API Endpoints
09:34 – Setup Fluent Validation
11:51 – Configure Minimal API Endpoints Filters
15:11 – Refactor Route Handler Filters

🥇 Credits:
Рекомендации по теме
Комментарии
Автор

Note to the newcomer: Some of the syntax used in this tutorial is from preview .NET 7 and will not work using release versions of .NET 7. Ex: .AddFilter< > should be .AddEndpointFilter < > and .Parameters should be .Arguments. Thanks for the video. Happy coding all ^

samjohnson
Автор

Your Tutorials are fantastic!!! Thank you for sharing

Azm
Автор

This is really clear and concise content buddy, massively impressed. With you delivery and the fact you're covering modern useful subjects in DotNet I really think you're on to a winner here. I've absolutely subscribed.

gavinwilliams
Автор

Can anyone explain to me why at 0:16:09 it's not recognizing my IRouteHandlerFilter or RouteHandlerInvocationContext or RouteHandlerFilterDelegate? I am using .NET 7. I also had to use AddEndpointFilter instead of AddFilter in my endpoint mapping. I also ended up going with var validator = // Note I had to use index 2 because I am using AutoMapper. Any help would be much appreciated! Great work Julian!

RandyBigbie
Автор

When the validation fails, the error should be "BadRequest", not "Problem". Because the issue is from the client request, not an error on the server.

maurovalvano
Автор

wow you are amazing!!! I don't know how I found you but you already have a new subscriber.

Do you have any example of Login with MAUI + .NET 6.0 (7.0)+ Bd (I would love to learn from you)
Thanks for sharing your knowledge ;-)

ivanxam
Автор

Hi Julian,

Thanks for this wonderful Video.

@12.58

In app.MapPost("/products", Create).AddFilter(async (context, next) =>);

Got context error - cs0103 the name context doest not exist in the current context.

unable to find namespace for RouteHandleInvocationContext as well.

Can you suggest a solution for this context error.

kumarangajapathy
Автор

Please make video on ef core stored procedure crud operation using.net 6

LearnifyGeek
Автор

@ 13:11 I get the following error for this...

var validator =

does not contain a definition for 'Parameters' and no accessible extension method 'Parameters' accepting a first argument of type

GuildOfCalamity
Автор

Julian, I really like your videos.

But some of them are missing something (I'm not sure if all, I haven't seen all yet), and it's a big problem for people like me, because almost nobody is showing how to do it.

For instance, people like me, who are trying to run our own business, there's almost no information at all on how to perform all the stuff you're sharing in your channel, such as authentication, authorization, etc, in production.

On every video you say logic things as "don't do this on production" "this is just an example for testing purposes", etc, and I get it.

I guess in real world scenarios, there's some devops and handful of seniors who manage the production phase on every company so this tutorials only focuses on programmers, but almost nobody (or at least I haven't found a good resource about this) is showing how to deploy to production with real examples on where to store keys, for instance, or optimize the project, and many other settings that at least I'm not sure if I'm doing it right.

So we are stuck in the middle, I have years (at least) learning .NET and C# and I understand all the fundamentals really good, even really advanced topics but since we haven't deployed anything for any company (I'm trying to create my own company), then we are not sure on how to do it. And I know I'm not the only one.

A great content would be complementing those videos where you say "don't do this or that" "it's for testing purposes only", etc, with real examples on how to actually do the thing. I have not much resources since I live in a third world country but I'm willing to help with a cheap VPS to show real deploys or something that would help us understand in a better way how things are done and not just theory. I know it's not much but for now it's what I could do.

There's some good professionals like Tim Corey but they're really expensive, so I have no option but do unsafe things and bad deploys, is there a chance you can create more content like that? in case you have that knowledge, of course. I think it's a niche with almost no competitors.

Thank you so much again for all your effort, it's priceless.

eduardrivas
join shbcf.ru