Dear Team,
I need to adjust the MSSQL Timeout for stored procedures.
Currently, there are 30 seconds.
I tried to adjust the property in the Radzen MSSQL properties, but it has no effect on application.
I use: Radzen 2.84.3 with .Net Core 6.0
Thank you
The timeout property is currently used in the connection string only to specify the connection timeout:
Connection Timeout=60
It is not used for command timeouts.
You can extend the EF context that Radzen has generated for your database via partial class and set the desired timeout:
namespace SampleAngular.Data
{
public partial class SampleContext
{
partial void OnModelBuilding(ModelBuilder builder)
{
Database.SetCommandTimeout(60);
}
}
}
Thank you for the code.
Unfortunately, I tried this code and I ended with the.Net error:
A DbContext instance cannot be used inside 'OnModelCreating' in any way that makes use of the model that is being created.
Is there something I miss?
I appreciate your help
Let's try something else. Extend the Startup like this:
public partial class Startup
{
partial void OnConfigureServices(IServiceCollection services)
{
services.AddDbContext<SampleAngular.Data.SampleContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("SampleConnection"),
sqlServerOptions => sqlServerOptions.CommandTimeout(60));
});
}
}
Replace Sample with the name of your database. This should set the command execution timeout.
1 Like
Thank you, this approach works.
Unfortunately, after the test, we found, that this approach does not modify command timeout.
Or this setting is somehow ignored.
I have used the code generation ignore list and added a row directly to the controller - that works but it is not the preferred solution.
I am afraid we don't have another solution.