2

I'm trying to scaffold Models from an existing database.

Scaffold-DbContext "connectionString" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

But I got this error:

Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

  • All required packages are installed (tried another connection string and it's working)
  • Tried (Connect timeout 15000 and Connection timeout 15000)
  • I can connect with the same connection string via Sql Server management / VS Server explorer

Any ideas?

Dale K
  • 25,246
  • 15
  • 42
  • 71
dr1sshamra
  • 81
  • 2
  • 9
  • I know you mentioned you can connect with the same connection string via Sql server management, but based on my experience - double check after double check. The most tough problems usually have the easiest solutions. – TommyTom Aug 23 '20 at 18:40
  • 3
    That's a CommandTimeout, not a connection timeout. Check for blocking on the server, in particular a DDL command in an uncommitted transaction. – David Browne - Microsoft Aug 23 '20 at 19:55
  • I tried to find active transaction didn't find anyone, for exemple i used "DBCC OPENTRAN". here is waht i got : No active open transactions. DBCC execution completed. If DBCC printed error messages, contact your system administrator. Any Idea ? – dr1sshamra Aug 24 '20 at 19:48

2 Answers2

1

For me, it worked with SQL Server 2019 (15) by adding Command Timeout=300 to the Connection String.

Tigerware
  • 3,196
  • 2
  • 23
  • 39
0

As far as I know there is no solution at the moment. The SQL Server connection string does not allow to define the command timeout, but only the connection timeout. I solved it using the --schema dbo option, which eliminated a dozen tables that have another schema, and now it works. But for how long?

My code:

dotnet ef dbcontext scaffold "SERVER=.;DATABASE=dbstore0;Integrated Security=SSPI;Connection Timeout=300;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -f -o DbStore\Models --context-dir DbStore\Contexts -c DbStoreContext -p Store.Domain.csproj --no-pluralize --schema dbo
benson23
  • 16,369
  • 9
  • 19
  • 38
Gian
  • 31
  • 4