1

I use VSTS and Git as source controller and Azure as host to my ASP.NET Core 2.1 API application, I'm trying to have a CI in VSTS, So every things worked except automatically update-database, I used EF core Code first and I need to update DB (in Azure) Automatically in CI process.

But For now, each time I update the connection string in my project(to Azure DB) and run the update-database manually.

For automatic CI process I find:

So I search in Debug Console to find package folder irst to set the command to use packages/migration.exe

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Microsoft.AspNetCore.AzureAppServices.SiteExtension\store\x86\netcoreapp2.1

enter image description here

I can't find any package folder, or entifyframework libraries

So how could I find the migration.exe file?

Is there any other way to have automatic update-database in VSTS build for EF Code first?

UPDATE:

Here is my nuget reference:

enter image description here

I add the copy file step:

enter image description here

And config is:

enter image description here

Bu I got the Error:

enter image description here

It seems the source folder path is not correct, What should I add as a Source folder?

Saeid
  • 13,224
  • 32
  • 107
  • 173
  • The blog posts you linked give pretty explicit step-by-step instructions. What isn't working with them? Migrate.exe is part of the NuGet package, it's not necessarily going to be packaged up and deployed in your webdeploy package. – Daniel Mann Jun 07 '18 at 18:21
  • @DanielMann, I update the question, I don't know what should I set as a source folder? – Saeid Jun 07 '18 at 18:57
  • Do you try to migration during deployment process? https://stackoverflow.com/questions/46784150/ef-core-code-first-deployment-vsts-pipeline-hospolicy-dll. Another thread that my benefit you: https://stackoverflow.com/questions/44746103/how-do-i-run-asp-net-core-entity-framework-migrations-from-visual-studio-team-se/46906087 – starian chen-MSFT Jun 08 '18 at 06:59

1 Answers1

0

I recommend that you can do migration during deploy process:

  1. Configure your web core project with EF migration: Migrations
  2. Create a publish profile with Entity Framework Migrations (Settings > Entity Framework Migrations)
  3. Include the publish profile to source control (include pubxml.user file to source control or copy ItemGroup section (<ItemGroup><EFMigrations …) to your publish profile (.pubxml))
  4. Publish web app through Visual Studio Build task (MSBuild Arguments: /p:DeployOnBuild=true /p:PublishProfile=CustomProfile;DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\myapp.zip")
  5. Deploy package (step4) to your site (e.g. through WinRM-IIS Web App Deployment task or Azure App Service Deploy task)
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Regarding step 4: What are the consequences of replacing `dotnet build` with Visual Studio Build task? how will be rest of the build pipeline affected? e.g. what to do with `dotnet publish` task – Liero Sep 10 '18 at 13:27
  • I wonder if it is possible to run dotnet ef update in during deploy, so that I don't have to change the build definition too much from the default one, – Liero Sep 10 '18 at 13:28
  • @Liero did you find a solution to this? I'm currently experimenting with my build – Adrian Nov 13 '19 at 02:15
  • @Adrian: No, I didn't :( – Liero Nov 13 '19 at 13:54