6

I'm trying to add a column to an existing table. It is simply a string column, not involved in any kind of keys and this is the only change I'm trying to make. I am creating the migration with the powershell call

dotnet ef migrations add [migration name] --context [context name]

As I've done many times before. I get an error that says.

An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: Invalid column name '[column id]'.

Unable to create an object of type 'DashboardContext'. Add an implementation of 'IDesignTimeDbContextFactory<[context name]>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.

Apparently this error means that the column doesn't exist, but that's precisely why I'm trying to create the migration - to add it.

EDIT: It turns out that adding the migration includes a call to Startup->Configure which in my case accessed that table. Any info on why that is the case would be appreciated. Meanwhile I got around it by commenting that code out while creating the migration.

bricelam
  • 28,825
  • 9
  • 92
  • 117
Kristaps Baumanis
  • 563
  • 1
  • 7
  • 18
  • 1
    Assuming it is a valid column name, you can try [these](https://stackoverflow.com/questions/45782446/unable-to-create-migrations-after-upgrading-to-asp-net-core-2-0) – Steve Greene Mar 01 '18 at 15:50

0 Answers0