Search code examples
aspnetboilerplate

How to migrate in Azure using ASP ABP?


How do we get migrations to work using ABP when using an Azure SQL server?

I tried myDbContext.Database.Migrate(); but myDbContext wants an options file.

I tried using Update-Database but it doesn't want to accept a ConnectionString.

I tried to enable migrations when publishing, but for some unknown reason, there is no "Migrate database on startup" option... very strange.

What's the right way to do this? SQL scripts?


Solution

  • You can pass a connection string to Update-Database command. Here's how to;

    Update-Database -Verbose -ConnectionString "Server=localhost;Database=MyDatabase;User=sa;Password=123;" -ConnectionProviderName "System.Data.SqlClient"
    

    Here's a sample Azure db connection with Update-Database

    Update-Database -StartUpProjectName "MyCloudProject" -ConnectionString "Server=tcp:<server_name>.database.windows.net,1433;Database=<database_name>;User ID=<db_user_name>@<server_name>;Password=<password>;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True;Max Pool Size=100;" -ConnectionProviderName "System.Data.SqlClient"