dotnetcore-buildpack: Error while running migrations with "heroku run dotnet ef database update"
I used this buildpack to deploy to a Heroku app, and since it’s a new deployment, I expected that I would need to run all the migrations to get the database ready for the app to run. Since I would run dotnet ef database update locally to do this, I figured I would heroku run dotnet ef database update to run this remotely. I have used Heroku before for Rails and I remember being able to do all the rake tasks by prepending them with heroku run.
When I run this though, it takes a long time to do something with the local package cache and then it displays an error message:
> heroku run dotnet ef database update
Running dotnet ef database update on ⬢ property-app-back-end... up, run.5524 (Free)
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 8288 ms
Expanding 100% 17908 ms
Version for package `Microsoft.EntityFrameworkCore.Tools.DotNet` could not be resolved.
Any idea what might be causing this?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 21 (18 by maintainers)
@luizs81 Thanks for bringing that up. I never considered it when I wrote my comment on Apr 15. I’ve since changed my approach to be more dynamic. I came up with an algorithm to parse the Heroku-style connection URL to a connection string that Npgsql can use. I’m glad you brought it up because anyone following my old comment may have had some issues in the future. 👍
Here is my new approach:
Hi @welkie,
Right,
heroku run dotnet ef database updatedoesn’t work after application has published.I suggest to add target to
csprojfile (https://github.com/jincod/AspNetHerokuTest/blob/9a38aae85790d7f11755e41e9844da606981758e/AspNetHerokuTest.csproj#L13-L15):Also I had to add some options to connection string
https://github.com/jincod/AspNetHerokuTest/commit/9a38aae85790d7f11755e41e9844da606981758e
Fixed project here https://github.com/jincod/AspNetHerokuTest
Let me know please, if it works for you
@jincod I’ll be testing this buildback again soon with 2.1. I’ll let you know if I experience this issue running migrations on remote again.
No seeding in
Startup. All start up time database work done inProgram. 😃