Efcore: RevEng: Command timeout should be configurable

Created on 28 Aug 2020  路  21Comments  路  Source: dotnet/efcore

area-scaffolding closed-wont-fix customer-reported type-enhancement

Most helpful comment

@ajcvickers Yes; the option is DefaultCommandTimeout: https://mysqlconnector.net/connection-options/#DefaultCommandTimeout.

All 21 comments

I would be interested in taking this if the scope is just a configurable timeout, if that's acceptable.

@svengeance Sure, propose how a user would configure it

Now, if only it was possible to change the default via the connection string! https://github.com/dotnet/SqlClient/issues/614

I outlined this a bit in the issue that this one rose from, but I could implement this in one of a few ways.

The easiest (well. ease-of-use wise) solution would be to introduce a new command line argument specifying a default timeout. This would then be carried forward from dotnet-ef and ef to EFCore.Design, and all the way to DbConnection resolution inside of SqlServerDatabaseModelFactory.
The primary benefit here is that the access point is up-front and easy to configure.

I had in my mind to attempt to bring in the same methodology of resolving DbContexts from IDesignTimeDbContextFactory, but I'm not sure if it feels weird to enact a database-first flow through a code-first design time context.
The primary benefit of this implementation is that it follows the same concept that Migrations. It is, of course, more complicated than a cmdline arg. Users would specify the context type ala migrations.

Lastly, we could potentially extend DatabaseModelFactory to include a timeout property. I need to verify, but I believe that users have the potential to extend this particular design time service through both migrations and scaffolding. Users could then create their own class extending from their provider-specific model factories (e.g. SqlServerDatabaseModelFactory) and override this field, which would give them a method that's not as intuitive, but has less internal moving parts.

Of these 3 proposals, did any of them align with your own ideas? None of them are breaking for existing users, and offer various levels of precedence, internal complexity, and ease-of-use.

and all the way to DbConnection resolution inside of SqlServerDatabaseModelFactory.

Keep in mind that the Timeout must be set on each command object.

Triage: This should be implemented as a new command line argument consistent with the arguments we already have for other commands. @bricelam to provide details.

In the meantime, I will try to implement this: https://github.com/dotnet/SqlClient/issues/614

@bricelam Ping for command line argument name

I'm with @ErikEJ on this one. No point adding an option if you can specify it in the connection string.

PR well underway

We discussed this and agreed that setting the command timeout in the connection string is the preferred way to add this functionality.

  • @ErikEJ is working on the PR for SQL Server dotnet/SqlClient#614
  • @bricelam to update M.D.Sqlite to support this #22505
  • @roji indicated that npgsql already supports this
  • @bgrainger Is setting the _command_ timeout in the connection string something that is supported by MySQL?
  • @JeremyLikness @roji Can one of you ping Oracle on this?

@ajcvickers Yes; the option is DefaultCommandTimeout: https://mysqlconnector.net/connection-options/#DefaultCommandTimeout.

Is there a de-facto keyword name? I was going to use Default Timeout to match System.Data.SQLite, but I'm happy to make that just an alias...

Looks like Command Timeout is the most common. I'll go with that.

MySqlConnector also supports Command Timeout (and Default Command Timeout) as an alias for the connection string option.

Looks like Oracle has Connect(ion) Timeout, but none for commands.

@cincuranet Wanna join the party and add a Command Timeout keyword too? 馃槈

Looks like IBM has Query Timeout.

@bricelam FirebirdClient does already support this (https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/54cfd145861345b46408642dea600a652e9e324d/Provider/src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnectionStringBuilder.cs#L126). ;)

@cincuranet This is about Command execution timeout, not about Connection timeout.

Thanks @ErikEJ. In that case it's tracked here.

Was this page helpful?
0 / 5 - 0 ratings