0

I have relatively large table with 7,517,717 records in my Azure SQL DB (which is on Azure V12 server, and it is on P4 pricing tier).

When I created table I forgot to define the MaxLength for a property, so now it is of type nvarchar(max).

I wanted to change this so I created migration (using FluentAPI) which looks like this:

 public partial class FeedTitleMaxLength : DbMigration
 {
    public override void Up()
    {
        AlterColumn("dbo.Feed", "Title", c => c.String(maxLength: 100));
    }

    public override void Down()
    {
        AlterColumn("dbo.Feed", "Title", c => c.String());
    }
 }

I've run Update-Database command like this:

Update-Database -Verbose -ConnectionString "Data Source=serverUrl,1433;Database=dbName;User ID=myusername;Password=mypassword;Trusted_Connection=False;Encrypt=True;Connection Timeout=3000;MultipleActiveResultSets=True;" -ConnectionProviderName "System.Data.SqlClient"

My connection string in web.config looks the same. And I've also defined timeout like this:

 this.Database.CommandTimeout = 3000;

But no matter what I do or try I get this error after 30/40 seconds:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. This failure occurred while attempting to connect to the routing destination. The duration spent while attempting to connect to the original server was - [Pre-Login] initialization=97; handshake=110; [Login] initialization=0; authentication=0; [Post-Login] complete=32;

Is there any way I can run this migration? Or some workaround? Can I, for example, create migration but run the AlterColumn command in SQL and then Update-Database command. Would this mess things or not?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
hyperN
  • 2,674
  • 9
  • 54
  • 92
  • 2
    Connection timeout doesn't help. You should set the *command timeout*, but that's not a connection string setting. Maybe [this](http://stackoverflow.com/q/24051417/861716) works for you. – Gert Arnold Nov 13 '16 at 12:32
  • @GertArnold this helped, thanks a lot :) – hyperN Nov 13 '16 at 13:00

0 Answers0