'how to solve timeout issue occured while updating the entries in database

A timeout error occurred while registering the record or updating the records in the database.

"The timeout period elapsed prior to completion of the operation or the server is not responding."

Application throw DbUpdateException error on running the update API.

Error below -

  • Microsoft.EntityFrameworkCore.DbUpdateException
  • System.ComponentModel.Win32Exception (258): The wait operation timed out.


Solution 1:[1]

The default value of CommandTimeout is 30s. You can modify it according to your needs.

In your Program.cs file (.Net 6),

builder.Services.AddDbContext<ApplicationDbContext>(
    options =>options.UseSqlServer(connectionString, op => 
        op.CommandTimeout(60)));

Or you can set it through your context.

Related Post:

What is the difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jason