Reputation: 3424
I'm creating an ASP.NET Core API, and I have one project in my solution named MyProj.API
and another project named MyProj.Data
. Both of them are Core Web app projects. Simply, API
project includes all the controllers and other logic, whereas the Data
project includes the models, context, repository and migrations. I have successfully hosted the app to Azure, but the point is that when publishing the API
project, there was no option to choose the migration to apply. Though, if I run the dotnet ef dbcontext list --json
command inside the API
project, it successfully shows to me the context that comes from the Data
project. Hence, I would like to learn whether there is a way to apply a migration manually to an app hosted in Azure?
Upvotes: 1
Views: 3428
Reputation: 566
You can applying migrations at runtime, or use Update-Database
with -ConnectionString
parameter in Visual Studio Package Management prompt.
For help, type Get-Help Update-Database -detailed
in the prompt.
Upvotes: -1
Reputation: 29950
For migration manually to .net core, you can follow this link .
You may need to manually run update-database
under Package Manager Console of VS, or you could use Powershell,
and cd to your project directory, and execute dotnet ef database update
to apply any pending migrations for your context to the database, then deploy your application to azure web app.
Detailed steps as below: In your visual studio -> Package Manager Console, run the following command:
1. dotnet ef migrations add AddProperty
2. dotnet ef database update
Then re-publish the project.
Moreover, you could also follow this similar issue.
Upvotes: 1