首页 > 其他分享 >System.InvalidOperationException: 'OnConfiguring' cannot be used to modify DbContextOption

System.InvalidOperationException: 'OnConfiguring' cannot be used to modify DbContextOption

时间:2023-03-14 15:14:51浏览次数:31  
标签:used when modify OnConfiguring System AddDbContextPool InvalidOperationException

报错原因因为你在依赖注入使用的是连接池AddDbContextPool,则不能在OnConfiguring配置参数 需要在AddDbContextPool中完成配置

builder.Services.AddDbContextPool<MyDbContext>(options =>
{
    options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
    options.UseSqlServer("xxxx");
});

 

标签:used,when,modify,OnConfiguring,System,AddDbContextPool,InvalidOperationException
From: https://www.cnblogs.com/hljjway/p/17214986.html

相关文章