-
Notifications
You must be signed in to change notification settings - Fork 226
Settings.CommandTimeout
The setting for when reading your schema is slow or appears to hang.
| Type |
int (seconds) |
| Default | 600 |
| Databases | All |
In Database.tt? |
Yes |
How long the efrpg tool waits for each schema query before giving up. 0 waits indefinitely.
Ten minutes sounds generous and occasionally is not. Reading a schema is a lot of queries against system tables, and on a large database with stale statistics some of them are slow - see below.
Settings.CommandTimeout = 1200; // 20 minutes
Settings.CommandTimeout = 0; // No limitRaising it treats the symptom. If you need more than ten minutes, something is wrong, and the two fixes
below are worth trying first. Use 0 only while diagnosing - a template that hangs forever is worse than one
that fails.
This is the design-time timeout. It has nothing to do with the timeout your application uses at run time,
which you set on the DbContext.
1. Turn off stored procedures. On SQL Server, discovering what a procedure returns means executing it
under SET FMTONLY ON, once per procedure. On a database with hundreds of procedures this is almost always
the entire runtime:
FilterSettings.IncludeStoredProcedures = false;
FilterSettings.IncludeTableValuedFunctions = false;
FilterSettings.IncludeScalarValuedFunctions = false;2. Update the statistics on the system tables. A well-documented SQL Server problem with a fix that takes seconds - see Speed up Reverse generating.
3. Filter down to the tables you need. Fewer tables is less to read, and a DbContext with 40 entities
also builds its model faster at run time than one with 900. See Filtering.
4. Only then raise the timeout.
CommandTimeout is per query, not for the whole run. A generation that takes twenty minutes across two
hundred queries never trips a ten-minute timeout.
A timeout surfaces as a partial result, not a crash. Each read is wrapped, so a failure is recorded as an error in the payload and the tool exits with code 2. You get generated code missing whatever failed to read, with the error as a comment - which is easy to miss.
It does not affect the generated code. It is about the design-time read.
- Speed up Reverse generating by updating statistics on sys tables
- Filtering - reading less in the first place
- SQL Server - why stored procedure discovery is the slow part
- Settings Reference
- Home
- Compared with the Microsoft scaffolder
- Connection strings
- JetBrains Rider
- Upgrading from v3 to v4
- Saving .tt does nothing
- Settings A-Z - every setting, with a page each
- Common Settings Types Explained
- Settings Callbacks
- Settings runtime values and helpers
- Filtering
- Full Control Over the Generated Code
- Enum Generation from Table Data
- Owned Entities
- JSON column support
- Global Query Filters
- Extended Property Names Feature
- Partial Properties
- File-Scoped Namespaces
- Data Annotations
- Spatial Types
- HierarchyId
- RowVersion and TimeStamp columns
- Lazy Loading
- Stored proc result sets