[Help Needed] Entity Framework update-database on a different database using pre-existing migrations?
Hello,
I have been working on a task for my company and have been using a local copy of SQL server on my machine for development.
The time has come to release it using our server (just another Windows PC with SQL server installed etc.).
I have been using code first migrations to develop my program with Entity Framework 6 and have about 5 migrations.
Now... I point the default connection string to the new database and attempted to run update-database... It didn't work as it wasn't ready for migrations.
Fair enough, I understand that... So I enable-migrations and then attempt to run the update-database command but I am getting the following error:
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. You can use the Add-Migration command to write the pending model changes to a code-based migration.
I was thinking maybe my VS had gone a bit funny so I ran add-migration "Test" just to see if it would output a blank migration. Instead, it made a migration for all of my models?
I did take out the data layer code that I was originally developing in my app with into it's own "class library" project and took the migrations folder with it to. The DbContext also resides in this new shared library project. This is the only thing I can think that may be causing this issue? I have made sure the project context in the package manager console is set to the shared library when running the migration command and it indeed does output the big migration in the migrations folder of the shared library folder... I just cant for the life of me understand why it is not seeing these pre-existing migrations??
Any help is much appreciated, Thanks!
0 comments:
Post a Comment