How to enable migrations in solution with docker-compose

When you try to enable migrations by running the command:
enable-migrations –MigrationsDirectory Migrations
in the solution with docker-compose project you get an error:

Exception calling “SetData” with “2” argument(s): “Type ‘Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject’ in assembly ‘Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ is
not marked as serializable.”

This is a feature of a solution with docker-compose suport. In order to avoid the error you should run any EF Command with -StartupProject “YourInitialAppProject” parameter.

For example to enable migrations use following command:

enable-migrations -StartupProject "YourModule.Web"

My solution:

  1. i’ve changed my startup project to the class library containing the context
  2. used command ‘enable-migrations’
  3. changed startup project to default one
2 Likes