Dapper use IDbConnection. I know the difference between Scoped and Transient but I wonder why some people register IDbConnection in DI container in Program.cs as Scoped and others as Transient. Is there any advantage one method over another?
services.AddScoped<IDbConnection>(sp =>
new SqlConnection(sp.GetRequiredService<IConfiguration>().GetConnectionString("DefaultConnection")));
--------------
services.AddTransient<IDbConnection>(sp =>
new SqlConnection(sp.GetRequiredService<IConfiguration>().GetConnectionString("DefaultConnection")));
1