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

Version 10.1 RC update-database fails with "More than one DbContext was found" #9926


User avatar
0
Mitch created
  • What is your product version? 10.1 RC
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? Net 5

I've just started to test version 10.1 RC. I'm following the getting started guide.

I set the Default Project in the Package Manager Console to EntityFrameworkCore.

I've got as far as running update-database but it fails with "More than one DbContext was found".


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Mitch

    Thanks, we will check this.

  • User Avatar
    0
    musa.demir created

    Hi @Mitch I checked that but could not reproduce the problem. Did you enable healtchecks? And can you please run dotnet ef dbcontext list command and share the result?

  • User Avatar
    0
    Mitch created

    Hi @musa.demir

    I hadn't enabled Health Checks myself, it seems they are Enabled by default in the appsettings.json file.

    "HealthChecks": { "HealthChecksEnabled": true, "HealthChecksUI": { "HealthChecksUIEnabled": true, "HealthChecks": [ { "Name": "xxxxxxx.Web.MVC", "Uri": "https://localhost:44302/health" } ], "EvaluationTimeOnSeconds": 10, "MinimumSecondsBetweenFailureNotifications": 60 } },

    As an experiment, I tried setting "HealthchecksEnabled" to false and as a result the issue with "More than one DbContext found" went away. So the issue is resolved as long as the HealthChecks are not Enabled.

  • User Avatar
    0
    samara081 created

    try Update-database -context "{Context calss name}"

  • User Avatar
    0
    Mitch created

    @samara081 Thanks for the tip.

    My point was that the Getting Started Guide just says to use "update-database" which is now incorrect as it no longer works with HeathChecksEnabled by default.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Mitch

    You are right, HeathChecksEnabled must be false by default. We will check this, thanks. I have created an issue https://github.com/aspnetzero/aspnet-zero-core/issues/3668