I just deployed an application into an azure App Service. My project does has migrations to be applied. But I was not able to apply them by using azure app command line
dotnet ef database update
D:\home\site\wwwroot> No executable found matching command "dotnet-ef"
How can I apply them remotely?
One of the best ways to run migrations on the Azure is running
update-database
command in the Visual Studio. But this command won't run. Your client IP address should have access to the Azure.You can follow RUN MIGRATIONS ON THE AZURE. Asp.Net Zero is built on top of Asp.Net Core so these steps will work for you.
For
dotnet-ef
, I assumed that you are talking about Entity Framework Core. I have tried to rundotnet ef database update
underD:\home\site\wwwroot
of KUDU and Package Manager Console of VS, I could encounter the same issue as you mentioned.I found a similar issue No executable found matching command "dotnet-ef":
I could run the commands
dotnet ef migrations add
,dotnet ef database update
via Powershell. For detailed command usage, you could follow EF Core .NET Command-line Tools.Per my understanding, you could not do that. You may need to manually run
update-database
as vivek nuna answered under Package Manager Console of VS, or you could use Powershell and cd to your project directory, and executedotnet ef database update
to apply any pending migrations for your context to the database, then deploy your application to azure web app.Additionally, EF does not support Automatic migrations, you may need to manually execute
Add-Migration
ordotnet ef migrations add
for adding migration files. You could explicitly execute the command to apply the migrations, also you could apply migrations in your code. And you could add the following code in theConfigure
method ofStartup.cs
file:Moreover, you could also follow this similar issue.
I had a very similiar problem. I am developing a .NET Core 3.0 web app (Visual Studio Angular template with Individual User Accounts). I'm using AzureDevops to build the project and publish it to an App Service on Azure.
First of all, you can use
in your pipeline to install ef extension for dotnet during the build process.
I assume you want to update a remote/production database. To do that in a secure manner, you can upload your appsettings.json file with specific credentials and connection string to Secure files in Azure Azure DevOps pipeline. See the picture below.
appsettings.json in Secure files
Then you can reference that file in your build pipeline by Download Secure File task (which downloads that file into the working directory of the build) and use dotnet ef database update like this :
migration script
Note that in the above migration script: