ASP.NET Core EF Add-Migration command not working

asp.net-core c# entity-framework-core visual-studio-2015

Question

Following this Microsoft Tutorial when I run the PM> Add-Migration MyFirstMigration command in VS2015 project created from the same tutorial I get the following error that I can't resolve:

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.

Point to note

  1. I'm using the above tutorial with the exception that I'm using Individual User Account authentication instead of No Authentication used in the tutorial.
  2. I've latest release of ASP.NeT Core 1.0 and VS2015-Update 3 on windows 8.1
  3. This is a freshly created project. No other DbContext was manually installed
1
37
7/2/2016 4:28:20 PM

Accepted Answer

Running the following command (obtained from this article) and a response from @Maverik (from STackoverflow here) and a suggestion from @doctor above helped me resolved the issue. Thank you all for your help:

PM> Add-Migration MyFirstMigration -Context BloggingContext
54
5/23/2017 12:02:34 PM

Popular Answer

The error clearly explains to mention --context with db Context name if more than one DbContext. So try by mentioning your DbContext name.

dotnet ef migrations add Initial --context SampleDbContext

Hope this helps.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow