My approach to have connection string in config file and use database context visible for migration is using context factory, like here: Entity Framework Core migration - connection string. Building migration works, but when I try to run actual migration:
dotnet ef database update
I get error:
More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.
For first I have no idea how it is possible to have several context since I have only one. Second problem, how to point out the factory (I cannot point out the context itself because it won't be configured properly, it is task of the factory).
As a temporary solution I executed migration from the C# code, but I would like to know how to do it from CLI (if this is possible at all with context factory).
Update 1: it looks like EF-tool is confused by its own output, because when I now have initial migration I can no longer execute creating another one (containing changes) -- I am getting the same error as above.
Update 2: using in factory my context type instead of generic DbContext
helped for now, but since I already encountered building migration failed with empty migrations (while previously it worked), I am not yet sure this is really a solution.