簡體   English   中英

如何使用 Autofac 注冊 DbContextPool?

[英]How to register DbContextPool using Autofac?

Microsoft 的 DI 有AddDbContextPool但如何使用Autofac呢?

所以,我想,對於像“如何注冊 Microsoft 的 DI(日志記錄、DbContext 等)中存在的東西? ”這樣的情況,標准的解決方法是使用ServiceCollection ,然后調用Populate方法。

我對DbContextPool的認識:

public static void RegisterDbContextPool<T>(this ContainerBuilder builder, Action<DbContextOptionsBuilder> options) where T : DbContext {
    var serviceCollection = new ServiceCollection();
    serviceCollection.AddDbContextPool<T>(options);
    builder.Populate(serviceCollection);
}

文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM