官术网_书友最值得收藏!

Pooling connections in Entity Framework Core 2.0

With the recent release of Entity Framework Core 2.0, we can pool connections by using the AddDbContextPool method in the Startup class. As we already know, in ASP.NET Core, we have to add the DbContext object using Dependency Injection (DI) in the ConfigureServices method in the Startup class, and when it is used in the controller, a new instance of the DbContext object is injected. To optimize performance, Microsoft has provided this AddDbContextPool method, which first checks for the available database context instance and injects it wherever it is needed. On the other hand, if the database context instance is not available, a new instance is created and injected.

The following code shows how AddDbContext can be added in the ConfigureServices method in the Startup class:

services.AddDbContextPool<SampleDbContext>( 
  options => options.UseSqlServer(connectionString)); 
There are some more features added to Owned Types, Table splitting, Database Scalar Function mapping, and string interpolation that you can refer to from the following link: https://docs.microsoft.com/en-us/ef/core/what-is-new/.
主站蜘蛛池模板: 万盛区| 调兵山市| 贵港市| 盐池县| 会同县| 潮安县| 大余县| 万荣县| 无极县| 银川市| 澄迈县| 句容市| 巧家县| 兰考县| 昌江| 民权县| 靖远县| 安陆市| 湾仔区| 内乡县| 凤凰县| 紫金县| 襄樊市| 祁阳县| 时尚| 天等县| 古蔺县| 六盘水市| 河津市| 五常市| 闸北区| 曲阜市| 郁南县| 灵山县| 怀化市| 内乡县| 兴隆县| 山阳县| 卓尼县| 南岸区| 安远县|