Open Closed

Running DbMigrator throws exception #9901


User avatar
0
cstobler created

When I run DbMigrator locally, I am receiving an exception:

I have never encountered this before. I suspect something is misconfigured or a reference is missing, but I have no idea what it might be.

I am going to email my project files over in case you need to take a look.

Thanks


14 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • The error "DbMigrator is not found!" indicates that the ABP CLI or Studio could not locate the DbMigrator project in your solution. This typically happens if the DbMigrator project is missing, not built, or not referenced correctly in your solution.

    How to resolve:

    1. Ensure the DbMigrator project exists in your solution directory.
    2. Make sure the project is included in your solution file (.sln). If not, right-click the solution in Visual Studio and add the existing project.
    3. Build the entire solution to ensure the DbMigrator executable is generated.
    4. If you renamed or moved the DbMigrator project, update all references and paths accordingly.
    5. Run the DbMigrator either from the command line or directly from Visual Studio as documented.
    # Example: Run from command line
    dotnet run --project path/to/YourProject.DbMigrator
    

    Reference:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    cstobler created

    Just to confirm, I confirmed that DbMigrator project exists, it is visible from my solution, I set it as startup project and attempted to run, I rebuilt by solution to check for errors or incompatibilities, and I attempted to run DbMigrator directly from command line. I also restarted Visual Studio just in case that was causing issues. So I think something is broken.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Do you have an EF Core migrations file in your EF Core project?

    Thanks.

  • User Avatar
    0
    cstobler created

    Yes, I created a new migration using "dotnet ef migrations add " followed by the migration name. That looks fine, as it shows the field I was adding.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to remove these lines?

  • User Avatar
    0
    cstobler created

    Hmm, it seems to be running now, but isn't playing nice with the migrations. It was throwing an exception saying it can't add a table that already exists. So I deleted all the existing migrations and the DbContextModelSnapshot (perhaps I shouldn't have done this but I thought it would reset it since it seems to be out of sync with the db), and made a new migration. I assumed it would recognize what is in the table and bring up a migration with just the differences, but it is wanting to insert all of the tables again. I'm not sure how this went wrong.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Your app will add initial EF Core migrations if it doesn't exist.

    If you want to remove all migrations, Just delete Migrations folder.

    BTW, there is an empty Armada.EntityFrameworkCore folder. Maybe you can try to remove it, I think this is why the app can't find the right folder.

    Thanks.

  • User Avatar
    0
    cstobler created

    I did end up cleaning up my project a bit, but I realized that the issue was the the __EFMigrations table was inconsistent with the migrations I had. I have no idea how that occurred (different ids), but I renamed some of my migrations to match, and had to comment out some code in one of the migrations that was already in the db. A bit hacky but I got it working. This is just a local dev environment so worst case scenario I can always drop the db and start over, but this is working for now.

    Thanks for your help.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great : )

  • User Avatar
    0
    cstobler created

    Decided to reopen this since I am having an issue with DbMigrator in my Github Workflow. This is also related to ticket #9542. I ran my Github workflow that runs on commit to deploy to Azure, and the DbMigrator didn't seem to work. I previously followed this guide: https://abp.io/docs/latest/solution-templates/layered-web-application/deployment/azure-deployment/step3-deployment-github-action?UI=MVC&DB=EF&Tiered=No. Here is the relevant part of the YML file: You can find the whole YML file on my github, which I gave access to you previously.

    When the workflow runs, it doesn't throw any errors, but it doesn't update the db as I would expect. I added a field that is not getting added to its table.

    One thing is that I don't see any command here to add a migration, it just runs DbMigrator. I didn't see that in the documentation I linked above, so I assumed it wasn't necessary, but maybe it is and I missed it.

    Any help would be really appreciated.

  • User Avatar
    0
    cstobler created

    I checked my Azure db ef migrations table, and it shows me this:

    Based on the number after Added_Payment_Module, which was different than the number after the same migration locally, it makes me think that it is automatically generated or something to that effect. However, I can't determine the mechanism behind this. For instance, I added the AddedToEmail migration locally:

    But obviously this isn't making its way into the ef migrations on the azure db.

    Please help me understand how this works and why the migration isn't working in this workflow.

  • User Avatar
    0
    cstobler created

    Based on everything I was seeing, it seems to me that it was attempting to use my local migrations to figure out what needs to go to the azure database. Unfortunately my migrations were very messed up (I made some changes to my project awhile ago and had some source control issues, so a lot of code got messed up), so I decided to nuke both of them and make fresh databases and a brand new initial migration, since I am still in development and can do so with very few downsides.

    If this ends up working, I will close the ticket.

  • User Avatar
    0
    cstobler created

    So nuking the databases (along with changing a connection string I missed, which might have been a big part of it) worked and everything is functional. I guess I was mostly just rubber duck debugging here so I will close this out.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 07, 2025, 05:59