Building Webhooks in .NET: Adding PostgreSQL Database Storage (part 2)

preview_player
Показать описание

In Part 1, we built a Webhooks system that worked great but lost all data when the app restarted. Now we're adding PostgreSQL to store both webhook subscriptions and delivery attempts, making our system production-ready and resilient. We'll walk through the full database implementation, including entity design, repository pattern setup, and proper error handling. This is a practical, no-nonsense guide to adding persistence to your Webhook system in .NET.

Building Async APIs in ASP.NET Core - The Right Way

Check out my courses:

Read my Blog here:

Join my weekly .NET newsletter:

Chapters
0:00 Adding EF Core
3:25 Using the DbContext
4:12 Aspire orchestration, PostgreSQL
5:59 Using the DbContext (continued)
12:11 Applying the DB Migration
Рекомендации по теме
Комментарии
Автор

Looking forward for part 3. I always enjoyed your optimization and scaling videos and blogs

antonmartyniuk
Автор

Great content to start the year with confidence. Happy new Year Milan and thanks as always for good content.

Maran-sr
Автор

Why we just using auto migration extension in Development Environment? Should we migrate our entities manually in Production?

omerabay
Автор

I don't like applying migrations on start of an application just simply because the application user that is used to the db connection may have super powers that may not be required for the application itself. I usually seggrate the the dbcontext along with the migration in a seperate dll, in my pipeline, i use the efcore cli to apply migrations then i deploy the webapp and starts it. Like that, i could use a different user to apply migrations in db, and use a db user with least permissions for my app.

Other than that, I really like the webhook approach, keep it up ! nice content !

franko
Автор

Why are you executing MigrateAsync only in development? Why not in general, doesn't it just do nothing if there are no new migration steps to be executed? How do you initiate migration in production?

lemao
Автор

awesome content, Will you do a series about Docker and .NET?

dotnetMasterCSharp
Автор

Added an outbox pattern to the DbContext and made the dispatcher a background service, interested to see your solution.

I hope you will introduce a resilience pipeline and track each delivery attempt as well, as this is something I haven't been able to get working yet.

cliffwakefield