The DbContext of type cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions

前端 未结 5 635
青春惊慌失措
青春惊慌失措 2020-12-08 11:36

I am trying to upgrade our current .Net Core application from 1.1 to 2.0 and am getting this runtime error: \"The DbContext of type \'CoreContext\' cannot be pooled because

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 12:18

    "because it does not have a single public constructor accepting a single parameter of type DbContextOptions"

    If you have any public constructors apart from one that accepts DbContextOptions, you need to remove them or make them non-public in order to use context pooling.

    Also, there are restrictions on what can be done by overriding the OnConfiguring method. This is referenced in the documentation here but it isn't explicit about what those restrictions are: https://docs.microsoft.com/en-us/ef/core/what-is-new/index#dbcontext-pooling

提交回复
热议问题