DbContext disposing?

后端 未结 1 997
予麋鹿
予麋鹿 2021-01-18 07:52

DbContext

public class HaberPortalDB : DbContext
{
    public DbSet Haberler { get; set; }
    public DbSet Kategoriler {          


        
相关标签:
1条回答
  • 2021-01-18 08:33

    A few things to note:

    • The lifetime of your controller is only as long as each request.
    • Each request will execute one action method.
    • Dispose is called when the controller completes the request.

    So, this is what happens during each request:

    1. Controller initialized
    2. DbContext initialized
    3. Action method executes
    4. Controller Dispose method executes
    0 讨论(0)
提交回复
热议问题