Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

getting error in update-database 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. #12171


User avatar
0
vvijaydeveloper created

Hi, I just purchased aspnetzero license and downloaded the code and tried to run the application but getting error at update-database command

"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."

Note : I did not modify and config settings.


7 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi vvijaydeveloper

    To perform the database migration, you can set the *.Migrator project as the Startup Project and run it to create the database. The *.Migrator project is also used for other purposes. You can check the details here.

    Alternatively, after opening the Package Manager Console, select the *.EntityFrameworkCore project from the Default Project dropdown menu at the top. Then, set the *.Web.Mvc or *.Web.Host project as the Startup Project through the Solution Explorer. You can update the database by entering the following command in the console:

    Update-Database
    

    or

    Update-Database -Context {{YourProjectName}}DbContext
    
  • User Avatar
    0
    glenasyncXViii created

    Hello Team

    Same experience "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."

    • The above suggestions are already in placed.

    This error message/prompt only showed on the latest version - 13.4. Previous version 13.3 was ok.

    Please advise and help us with this.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @glenasyncXViii,

    I tried it and it is running with -Context param. I'll check it with the ANZ 13.3 version.

  • User Avatar
    0
    pliaspzero created

    We have same issue pls help!

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @pliaspzero,

    You can resolve your problem with using -Context flag as below:

    Update-Database -Context {{Your_DBContext_Name}}

  • User Avatar
    0
    ashgadala created

    I dont get this one. Why this is not updated in the documentation. https://docs.aspnetzero.com/aspnet-core-mvc/latest/Getting-Started-Core

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @ashgadala,

    We will fix this in next version.