MVC, DbContext and Multithreading

前端 未结 2 632
悲&欢浪女
悲&欢浪女 2020-12-19 14:22

There are lots of questions about these subjects separately and everyone have their own opinion. Maybe someone can give me a good answer regarding the following issue.

相关标签:
2条回答
  • 2020-12-19 14:26

    The DbContext is a very light object and it is designed to be created for each operation (=request) and then disposed. Under the hood ado.net takes care of reusing db connection from connection pool.

    0 讨论(0)
  • 2020-12-19 14:35

    The DbContext is designed to be instantiated with each request. It implements IDisposable and instantiating is a low-cost operation. Connection pooling to the database is handled internally.

    More Information:

    Entity Framework and Connection Pooling

    0 讨论(0)
提交回复
热议问题