Starting Entity Framework migration during Octopus CI deployment to Azure

I need to set up a continuous integration process to deploy our application as an Azure cloud service using Octopus Deploy. This process includes the stage that performs the Entity Framework 6.1 migration with our Azure SQL database (by running migrate.exe from the Octopus local tentacle). However, port 1433 will need to be opened on the Octopus machine for this to work, and our administrator will not.

Is there any other way to suggest that Entity Framework migrations occur during an automatic deployment process?

+6
source share
2 answers

We completed the opening of this port because we could not find another solution. For reference, here we run the script (our Deploy.ps1 script, executed by NuGet for each deployment).

 # SOURCE: http://danpiessens.com/blog/2014/06/10/deploying-databases-with-octopus-deploy-part-2/ # Get the exe name based on the directory $contentPath = (Join-Path $OctopusOriginalPackageDirectoryPath "content") $fullPath = (Join-Path $OctopusOriginalPackageDirectoryPath "content\migrate.exe") Write-Host "Content Path:" $contentPath Write-Host "Migrate Path:" $fullPath cd $contentPath write-host "Working Dir: "$(get-location) # Run the migration utility & "$fullPath" MyApp.Data.dll /startUpConfigurationFile=MyApp.Web.dll.config /connectionString=$ApplicationConnectionString /connectionProviderName="System.Data.SqlClient" /verbose | Write-Host 
+2
source

I run migrations when the application starts using this code:

  class ApplicationDataContext : DbContext { internal static void UpdateDatabase() { Database.SetInitializer<ApplicationDataContext>(null); var settings = new Migrations.Configuration(); var migrator = new DbMigrator(settings); migrator.Update(); } } 
+1
source

Source: https://habr.com/ru/post/984602/


All Articles