I\'m using EF migrations and have a table with a lot of data. I need to change MaxLength of a concrete column (it hadn\'t length constraints).
ALTER TABLE MyDb A
Alternatively script out the change by using
Update-Database -script
You can then take the script and run it using SQL Management Studio against the database.
Found solution by myself.
Since EF5 there is a new property CommandTimeout which is available from DbMigrationsConfiguration
internal sealed class MyMigrationConfiguration : DbMigrationsConfiguration<MyDbContext>
{
public Configuration()
{
CommandTimeout = 10000; // migration timeout
}
}
I just had almost the exact same thing: timeout expired when trying to increase a column length. For me, using update-database
had been working just fine an hour ago. The problem turned out to be an open transaction on the database and table I was trying to alter. Once I rolled back that transaction, the update-database
command went through without problems.
In my case the issue was caused by a very large query which timed out in EF but was able to complete in SSMS.
The answer which suggests Update-Database -script
did not work for me, it gave another error message.
For me, I did the following:
Disclaimer: This might not work for all cases, because it depends on what particular query is slowing you down. For me, it worked.