Reputation: 49
So I have an ASP.NET MVC application that I deploy on the IIS using the Publish feature inside of Visual Studio. I have performed some changes to the existing version of the database and the application - this is what I did: I made very little changes to the database on the production server (just added a single column to two tables and made them FK to another table). Then I took the generate script from this production DB, went to the local (development) SQL server and ran the generate script to create the database locally. After this, scaffolded this local DB instance into VS (to get the modified model classes locally). Then, after some smaller modifications to the app (I was basically just adding some document upload functionality), I did the Publish and deployed that on the production server.
However, I ran into the following error when I tried to log in the website: error screenshot
Why does this happen? How can applying the migrations work through Visual Studio package manager command if I run the suggested Update-Database
command locally (and from there I cannot reach the target database)?
Thank you very much for your help.
Upvotes: 1
Views: 611
Reputation: 1108
You need to add migration for your changes, as below :
Add-Migration Version2
it generates migration files, then you can run
Update-Database
to apply changes in the database. You can not manually migrate the database changes. It should be under Add-Migration command to create a new migration version.
Upvotes: 1