Base solution for your next web application
Open Closed

AutomaticMigrationsDisabledException in Migrator Project #2210


User avatar
0
ruffzy created

Hi,

when I run the Migrator project to create a new Migration I'll get an AutomaticMigrationsDisabledException. And the message is: Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

In another post I have seen that I would make sense now to run the database update command in the package manager console. But when I run Update-Database I get again an error: No DbContext was found in assembly 'enio.Web_Manager.EntityFramework'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

Btw, I have selected EntityFramework as my Default project in the drop down list. What is also a bit strange is that I also receive the following message:

Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Update-Database' for Entity Framework 6.

When I try executing EntityFramework\Update-Database I get the following exception: The EntityFramework package is not installed on project 'enio.Web_Manager.EntityFramework'.

Can you please give me an idea where to look for a solution? Do I have to use the commands for Entity Framework Core or Entity Framework 6 ?


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

    Hi,

    If you are using ASP.NET Core version, you should use "dotnet ef database update" command, see DATABASE MIGRATIONS section of this document <a class="postlink" href="https://aspnetzero.com/Documents/Developing-Step-By-Step-Core">https://aspnetzero.com/Documents/Develo ... -Step-Core</a>.

    Otherwise, you should use Update-Database command.

    There is a missunderstanding I think, Migrator tool is not for creating migrations, it is for updating databases.